Class: BusinessFlow::DSL::MemoizedField
- Inherits:
-
Object
- Object
- BusinessFlow::DSL::MemoizedField
- Defined in:
- lib/business_flow/dsl.rb
Overview
Helper class around memoized fields
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Instance Method Summary collapse
- #add_to(klass) ⇒ Object
-
#initialize(field, retriever, setter_factory) ⇒ MemoizedField
constructor
A new instance of MemoizedField.
- #name ⇒ Object
Constructor Details
#initialize(field, retriever, setter_factory) ⇒ MemoizedField
Returns a new instance of MemoizedField.
430 431 432 433 434 |
# File 'lib/business_flow/dsl.rb', line 430 def initialize(field, retriever, setter_factory) @field = field @retriever = retriever @setter_factory = setter_factory end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
428 429 430 |
# File 'lib/business_flow/dsl.rb', line 428 def field @field end |
Instance Method Details
#add_to(klass) ⇒ Object
436 437 438 439 440 441 |
# File 'lib/business_flow/dsl.rb', line 436 def add_to(klass) setter = setter_factory.call(field, safe_ivar_name) Field.unsafe_eval_method( klass, field, memoized(safe_ivar_name, setter, retriever) ) end |
#name ⇒ Object
443 444 445 |
# File 'lib/business_flow/dsl.rb', line 443 def name field end |