Module: LedgerSync::Serialization::Mixin::ClassMethods
- Defined in:
- lib/ledger_sync/serialization/mixin.rb
Instance Method Summary collapse
- #_attribute(args) ⇒ Object
- #_build_attribute(args) ⇒ Object
-
#attribute(_hash_attribute, _args = {}, &_block) ⇒ Serializer::Attribute
Class method for defining de/serializer attributes.
- #attribute_class ⇒ Object
- #attributes ⇒ Object
- #references_many(args = {}) ⇒ Object
- #references_one(args = {}) ⇒ Object
Instance Method Details
#_attribute(args) ⇒ Object
44 45 46 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 44 def _attribute(args) attributes.add(_build_attribute(args)) end |
#_build_attribute(args) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 48 def _build_attribute(args) block = args.fetch(:block, nil) hash_attribute = args.fetch(:hash_attribute) resource_attribute = args.fetch(:resource_attribute, nil) resource_class = args.fetch(:resource_class, nil) serializer = args.fetch(:serializer, nil) type = args.fetch(:type, nil) attribute_class.new( block: block, hash_attribute: hash_attribute, resource_attribute: resource_attribute, resource_class: resource_class, serializer: serializer, type: type ) end |
#attribute(_hash_attribute, _args = {}, &_block) ⇒ Serializer::Attribute
Class method for defining de/serializer attributes
16 17 18 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 16 def attribute(_hash_attribute, _args = {}, &_block) raise NotImplementedError end |
#attribute_class ⇒ Object
20 21 22 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 20 def attribute_class raise NotImplementedError end |
#attributes ⇒ Object
24 25 26 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 24 def attributes raise NotImplementedError end |
#references_many(args = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 28 def references_many(args = {}) _attribute( { type: Type::ReferencesManyType.new(serializer: self) }.merge(args) ) end |
#references_one(args = {}) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/ledger_sync/serialization/mixin.rb', line 36 def references_one(args = {}) _attribute( { type: Type::ReferencesOneType.new(serializer: self) }.merge(args) ) end |