Class: Serega::AttributeValueResolvers::HashAccessDelegateAllowNil
- Inherits:
-
Object
- Object
- Serega::AttributeValueResolvers::HashAccessDelegateAllowNil
- Defined in:
- lib/serega/attribute_value_resolvers/hash_access.rb
Overview
Value resolver for attributes with :hash_access and :delegate (with :allow_nil) options
Instance Method Summary collapse
-
#call(object) ⇒ Object?
Delegates the value reading through the intermediate object, resolving a nil intermediate to nil.
-
#initialize(to_step, final_step) ⇒ HashAccessDelegateAllowNil
constructor
A new instance of HashAccessDelegateAllowNil.
Constructor Details
#initialize(to_step, final_step) ⇒ HashAccessDelegateAllowNil
Returns a new instance of HashAccessDelegateAllowNil.
102 103 104 105 |
# File 'lib/serega/attribute_value_resolvers/hash_access.rb', line 102 def initialize(to_step, final_step) @to_step = to_step @final_step = final_step end |
Instance Method Details
#call(object) ⇒ Object?
Delegates the value reading through the intermediate object, resolving a nil intermediate to nil
114 115 116 117 118 119 |
# File 'lib/serega/attribute_value_resolvers/hash_access.rb', line 114 def call(object) intermediate = @to_step.call(object) return if intermediate.nil? @final_step.call(intermediate) end |