Module: Actions::Action
- Defined in:
- lib/actions/action.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context = {}) ⇒ Object
FIXME: Handle context failures more gracefully, i.e.
Class Method Details
.included(base) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/actions/action.rb', line 10 def self.included(base) base.class_eval do prepend Storage prepend ErrorHandling extend ClassMethods attr_reader :context end end |
Instance Method Details
#initialize(context = {}) ⇒ Object
FIXME: Handle context failures more gracefully, i.e. don’t initialize a new action if one in the group failed previously.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/actions/action.rb', line 45 def initialize(context = {}) @context = SafeContext.new(context) if @context.success? && (self.class.inputs.any? || self.class.outputs.any?) @context.action = self self.class.inputs.each do |name, | @context.input!(name, type: [:type], mutable: [:mutable], required: [:required]) end self.class.outputs.each do |name, | @context.output!(name, type: [:type]) end else @context = Context.build(context) @context.action = self end end |