Class: BusinessFlow::DSL::UsesField
- Inherits:
-
Object
- Object
- BusinessFlow::DSL::UsesField
- Defined in:
- lib/business_flow/dsl.rb
Overview
Responsible for declaring fields which will be memoized and validated when first set
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_to(klass) ⇒ Object
-
#initialize(field, retriever) ⇒ UsesField
constructor
A new instance of UsesField.
Constructor Details
#initialize(field, retriever) ⇒ UsesField
Returns a new instance of UsesField.
474 475 476 477 478 479 |
# File 'lib/business_flow/dsl.rb', line 474 def initialize(field, retriever) @name = field @retriever = retriever @field = MemoizedField.new(field, retriever_method_name, Field.method(:setter_factory)) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
472 473 474 |
# File 'lib/business_flow/dsl.rb', line 472 def name @name end |
Instance Method Details
#add_to(klass) ⇒ Object
481 482 483 484 485 486 |
# File 'lib/business_flow/dsl.rb', line 481 def add_to(klass) klass.send(:define_method, retriever_method_name, &@retriever) klass.send(:private, retriever_method_name) @field.add_to(klass) klass.send(:public, @name) end |