Class: Attrify::Variant
- Inherits:
-
Object
- Object
- Attrify::Variant
- Includes:
- Helpers
- Defined in:
- lib/attrify/variant.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#has_procs ⇒ Object
readonly
Returns the value of attribute has_procs.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #adjust(hash) ⇒ Object
-
#initialize(operations) ⇒ Variant
constructor
A new instance of Variant.
Methods included from Helpers
#compute_attributes, #deep_merge_hashes, #deep_merge_hashes!, #execute_operation
Constructor Details
#initialize(operations) ⇒ Variant
Returns a new instance of Variant.
13 14 15 16 17 18 19 20 |
# File 'lib/attrify/variant.rb', line 13 def initialize(operations) @operations = operations result = cache_result(operations) @has_procs = result[:has_procs] @attributes = result[:value] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/attrify/variant.rb', line 10 def attributes @attributes end |
#has_procs ⇒ Object (readonly)
Returns the value of attribute has_procs.
11 12 13 |
# File 'lib/attrify/variant.rb', line 11 def has_procs @has_procs end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
9 10 11 |
# File 'lib/attrify/variant.rb', line 9 def operations @operations end |
Instance Method Details
#adjust(hash) ⇒ Object
22 23 24 |
# File 'lib/attrify/variant.rb', line 22 def adjust(hash) OperationSet.new(deep_merge_hashes(@operations, hash)) end |