Module: ServiceActor::Attributable::ClassMethods
- Defined in:
- lib/service_actor/attributable.rb
Instance Method Summary collapse
- #inherited(child) ⇒ Object
- #input(name, **arguments) ⇒ Object
- #inputs ⇒ Object
- #output(name, **arguments) ⇒ Object
- #outputs ⇒ Object
Instance Method Details
#inherited(child) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/service_actor/attributable.rb', line 17 def inherited(child) super child.inputs.merge!(inputs) child.outputs.merge!(outputs) end |
#input(name, **arguments) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/service_actor/attributable.rb', line 24 def input(name, **arguments) ServiceActor::ArgumentsValidator.validate_origin_name( name, origin: :input, ) ServiceActor::ArgumentsValidator.validate_default_value( arguments[:default], actor: self, origin_type: :input, origin_name: name, ) inputs[name] = arguments define_method(name) do result[name] end # To avoid method redefined warning messages. alias_method(name, name) if method_defined?(name) protected name end |
#inputs ⇒ Object
49 50 51 |
# File 'lib/service_actor/attributable.rb', line 49 def inputs @inputs ||= {} end |
#output(name, **arguments) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/service_actor/attributable.rb', line 53 def output(name, **arguments) ServiceActor::ArgumentsValidator.validate_origin_name( name, origin: :output, ) ServiceActor::ArgumentsValidator.validate_default_value( arguments[:default], actor: self, origin_type: :output, origin_name: name, ) outputs[name] = arguments define_method(name) do result[name] end protected name define_method(:"#{name}=") do |value| result[name] = value end protected :"#{name}=" end |
#outputs ⇒ Object
79 80 81 |
# File 'lib/service_actor/attributable.rb', line 79 def outputs @outputs ||= {} end |