Class: Rumx::Operation
- Inherits:
-
Object
- Object
- Rumx::Operation
- Defined in:
- lib/rumx/operation.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type_name, description, arguments) ⇒ Operation
constructor
A new instance of Operation.
- #run(bean, argument_hash) ⇒ Object
Constructor Details
#initialize(name, type_name, description, arguments) ⇒ Operation
Returns a new instance of Operation.
5 6 7 8 9 10 |
# File 'lib/rumx/operation.rb', line 5 def initialize(name, type_name, description, arguments) @name = name.to_sym @type = Type.find(type_name) @description = description @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
3 4 5 |
# File 'lib/rumx/operation.rb', line 3 def arguments @arguments end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/rumx/operation.rb', line 3 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rumx/operation.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/rumx/operation.rb', line 3 def type @type end |
Instance Method Details
#run(bean, argument_hash) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rumx/operation.rb', line 12 def run(bean, argument_hash) args = @arguments.map do |argument| if argument_hash.has_key?(argument.name) value = argument_hash[argument.name] elsif argument_hash.has_key?(argument.name.to_s) value = argument_hash[argument.name.to_s] else raise "No value for argument #{argument.name}" end argument.type.string_to_value(value) end bean.send(self.name, *args) end |