Class: LedgerSync::Ledgers::TestLedger::Serializer
- Inherits:
-
Serializer
- Object
- Serializer
- LedgerSync::Ledgers::TestLedger::Serializer
show all
- Defined in:
- lib/ledger_sync/test/support/test_ledger/serializer.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Serializer
attribute, attribute_class, attributes, references_many, references_one, serializer_from
included
Class Method Details
.amount(hash_attribute, args = {}) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/ledger_sync/test/support/test_ledger/serializer.rb', line 26
def self.amount(hash_attribute, args = {})
attribute(
hash_attribute,
{
type: Serialization::Type::IntegerToAmountFloatType.new
}.merge(args)
)
end
|
.date(hash_attribute, args = {}) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/ledger_sync/test/support/test_ledger/serializer.rb', line 35
def self.date(hash_attribute, args = {})
attribute(
hash_attribute,
{
type: LedgerSync::Serialization::Type::FormatDateType.new(format: '%Y-%m-%d')
}.merge(args)
)
end
|
.id ⇒ Object
44
45
46
|
# File 'lib/ledger_sync/test/support/test_ledger/serializer.rb', line 44
def self.id
attribute('Id', resource_attribute: :ledger_id)
end
|
Instance Method Details
#serialize(args = {}) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/ledger_sync/test/support/test_ledger/serializer.rb', line 9
def serialize(args = {})
deep_merge_unmapped_values = args.fetch(:deep_merge_unmapped_values, {})
only_changes = args.fetch(:only_changes, false)
resource = args.fetch(:resource)
ret = super(
only_changes: only_changes,
resource: resource
)
return ret unless deep_merge_unmapped_values.any?
deep_merge_if_not_mapped(
current_hash: ret,
hash_to_search: deep_merge_unmapped_values
)
end
|