Class: OFX::Data::Serialization::Registry
- Inherits:
-
Object
- Object
- OFX::Data::Serialization::Registry
- Defined in:
- lib/ofx/data/serialization/registry.rb,
lib/ofx/data/serialization/registry/entry.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #matching_entry(ofx_type, context_name) ⇒ Object
- #register(entry) ⇒ Object
- #serializer_for(ofx_type, context_name = nil) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
15 16 17 |
# File 'lib/ofx/data/serialization/registry.rb', line 15 def initialize @entries = [] end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
13 14 15 |
# File 'lib/ofx/data/serialization/registry.rb', line 13 def entries @entries end |
Class Method Details
.build(&block) ⇒ Object
7 8 9 10 11 |
# File 'lib/ofx/data/serialization/registry.rb', line 7 def self.build(&block) registry = new block.call(registry) registry end |
Instance Method Details
#matching_entry(ofx_type, context_name) ⇒ Object
23 24 25 26 27 |
# File 'lib/ofx/data/serialization/registry.rb', line 23 def matching_entry(ofx_type, context_name) match = entries.find { |entry| entry.match?(ofx_type, context_name) } raise SerializerNotFoundError.generate(ofx_type, context_name) if match.nil? match end |
#register(entry) ⇒ Object
19 20 21 |
# File 'lib/ofx/data/serialization/registry.rb', line 19 def register(entry) entries << entry end |
#serializer_for(ofx_type, context_name = nil) ⇒ Object
29 30 31 |
# File 'lib/ofx/data/serialization/registry.rb', line 29 def serializer_for(ofx_type, context_name = nil) matching_entry(ofx_type, context_name).serializer end |