Class: Attrify::Variant

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/attrify/variant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/attrify/variant.rb', line 10

def attributes
  @attributes
end

#has_procsObject (readonly)

Returns the value of attribute has_procs.



11
12
13
# File 'lib/attrify/variant.rb', line 11

def has_procs
  @has_procs
end

#operationsObject (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