Class: Transformator::Transformation::Step
- Inherits:
-
Object
- Object
- Transformator::Transformation::Step
- Defined in:
- lib/transformator/transformation/step.rb
Instance Attribute Summary collapse
-
#transformation ⇒ Object
Returns the value of attribute transformation.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(transformation = nil, options = {}) ⇒ Step
constructor
A new instance of Step.
-
#method_missing(method_name, *args, &block) ⇒ Object
Each step has transparent access to all methods of it’s transformation.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
-
#source ⇒ Object
avoid method_missing penalty for the most used transformation methods.
- #source=(value) ⇒ Object
- #target ⇒ Object
- #target=(value) ⇒ Object
Constructor Details
#initialize(transformation = nil, options = {}) ⇒ Step
Returns a new instance of Step.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/transformator/transformation/step.rb', line 6 def initialize(transformation = nil, = {}) if transformation.is_a?(Hash) = transformation transformation = nil end if transformation @transformation = transformation else @transformation = Struct.new(:source, :target).new.tap do |_struct| _struct.source = [:source] _struct.target = [:target] end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
Each step has transparent access to all methods of it’s transformation
28 29 30 31 32 33 34 |
# File 'lib/transformator/transformation/step.rb', line 28 def method_missing(method_name, *args, &block) if @transformation.respond_to?(method_name) @transformation.send(method_name, *args, &block) else super end end |
Instance Attribute Details
#transformation ⇒ Object
Returns the value of attribute transformation.
4 5 6 |
# File 'lib/transformator/transformation/step.rb', line 4 def transformation @transformation end |
Instance Method Details
#call ⇒ Object
22 23 |
# File 'lib/transformator/transformation/step.rb', line 22 def call end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
36 37 38 |
# File 'lib/transformator/transformation/step.rb', line 36 def respond_to_missing?(method_name, include_private = false) @transformation.respond_to?(method_name) || super end |
#source ⇒ Object
avoid method_missing penalty for the most used transformation methods
41 |
# File 'lib/transformator/transformation/step.rb', line 41 def source; @transformation.source; end |
#source=(value) ⇒ Object
42 |
# File 'lib/transformator/transformation/step.rb', line 42 def source=(value); @transformation.source=(value); end |
#target ⇒ Object
43 |
# File 'lib/transformator/transformation/step.rb', line 43 def target; @transformation.target; end |
#target=(value) ⇒ Object
44 |
# File 'lib/transformator/transformation/step.rb', line 44 def target=(value); @transformation.target=(value); end |