Class: LedgerSync::Serialization::Attribute
- Inherits:
-
Object
- Object
- LedgerSync::Serialization::Attribute
show all
- Defined in:
- lib/ledger_sync/serialization/attribute.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args = {}) ⇒ Attribute
14
15
16
17
18
19
20
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 14
def initialize(args = {})
@block = args.fetch(:block, nil)
@hash_attribute = args.fetch(:hash_attribute, nil).try(:to_s)
@resource_attribute = args.fetch(:resource_attribute, nil).try(:to_s)
@resource_class = args.fetch(:resource_class, nil)
@type = args.fetch(:type, nil) || Type::ValueType.new
end
|
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
8
9
10
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 8
def block
@block
end
|
#hash_attribute ⇒ Object
Returns the value of attribute hash_attribute.
8
9
10
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 8
def hash_attribute
@hash_attribute
end
|
#resource_attribute ⇒ Object
Returns the value of attribute resource_attribute.
8
9
10
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 8
def resource_attribute
@resource_attribute
end
|
#resource_class ⇒ Object
Returns the value of attribute resource_class.
8
9
10
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 8
def resource_class
@resource_class
end
|
#type ⇒ Object
Returns the value of attribute type.
8
9
10
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 8
def type
@type
end
|
Instance Method Details
#block_value_for(args = {}) ⇒ Object
22
23
24
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 22
def block_value_for(args = {})
block.call(args.merge(attribute: self))
end
|
#hash_attribute_dot_parts ⇒ Object
26
27
28
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 26
def hash_attribute_dot_parts
@hash_attribute_dot_parts ||= hash_attribute.split('.')
end
|
#reference? ⇒ Boolean
30
31
32
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 30
def reference?
references_many? || references_one?
end
|
#references_many? ⇒ Boolean
34
35
36
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 34
def references_many?
type.is_a?(Type::ReferencesManyType)
end
|
#references_one? ⇒ Boolean
38
39
40
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 38
def references_one?
type.is_a?(Type::ReferencesOneType)
end
|
#resource_attribute_dot_parts ⇒ Object
42
43
44
|
# File 'lib/ledger_sync/serialization/attribute.rb', line 42
def resource_attribute_dot_parts
@resource_attribute_dot_parts ||= resource_attribute.split('.')
end
|