Class: Reforge::Transformation::Transform
- Inherits:
-
Object
- Object
- Reforge::Transformation::Transform
- Includes:
- Factories
- Defined in:
- lib/reforge/transformation/transform.rb,
lib/reforge/transformation/transform/memo.rb,
lib/reforge/transformation/transform/factories.rb
Defined Under Namespace
Modules: Factories Classes: Memo
Constant Summary
Constants included from Factories
Factories::TRANSFORM_PROC_FACTORIES, Factories::TRANSFORM_TYPES
Instance Attribute Summary collapse
-
#transform ⇒ Object
readonly
Returns the value of attribute transform.
Instance Method Summary collapse
- #call(source) ⇒ Object
-
#initialize(transform, memoize: nil) ⇒ Transform
constructor
A new instance of Transform.
Methods included from Factories
Constructor Details
#initialize(transform, memoize: nil) ⇒ Transform
Returns a new instance of Transform.
10 11 12 13 14 15 16 |
# File 'lib/reforge/transformation/transform.rb', line 10 def initialize(transform, memoize: nil) transform = transform_proc_from(transform) if transform.is_a?(Hash) validate_transform!(transform) @transform = transform @memo = Memo.from(memoize) if memoize end |
Instance Attribute Details
#transform ⇒ Object (readonly)
Returns the value of attribute transform.
8 9 10 |
# File 'lib/reforge/transformation/transform.rb', line 8 def transform @transform end |
Instance Method Details
#call(source) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/reforge/transformation/transform.rb', line 18 def call(source) if @memo.nil? call_transform(source) else @memo[source] ||= call_transform(source) end end |