Class: OFX::Configuration::SectionProxy
- Inherits:
-
Object
- Object
- OFX::Configuration::SectionProxy
- Defined in:
- lib/ofx_kit/configuration/section_proxy.rb
Overview
Proxy object returned by section accessors (e.g. OFX.config.transaction). Provides a fluent interface for adding individual user-layer field mappings.
Instance Method Summary collapse
-
#initialize(user_fields, core_fields, xml_tag) ⇒ SectionProxy
constructor
A new instance of SectionProxy.
-
#map(xml_key, to:) ⇒ Object
Maps an OFX XML key to a Ruby attribute name for this section.
Constructor Details
#initialize(user_fields, core_fields, xml_tag) ⇒ SectionProxy
Returns a new instance of SectionProxy.
8 9 10 11 12 |
# File 'lib/ofx_kit/configuration/section_proxy.rb', line 8 def initialize(user_fields, core_fields, xml_tag) @user_fields = user_fields @core_fields = core_fields @xml_tag = xml_tag end |
Instance Method Details
#map(xml_key, to:) ⇒ Object
Maps an OFX XML key to a Ruby attribute name for this section.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ofx_kit/configuration/section_proxy.rb', line 18 def map(xml_key, to:) core_attr = @core_fields.dig(@xml_tag.to_s, xml_key.to_s) if core_attr raise OFX::ConfigurationError, "Cannot override core mapping '#{@xml_tag}.#{xml_key}' (reserved as '#{core_attr}')" end @user_fields[@xml_tag] ||= {} @user_fields[@xml_tag][xml_key] = to end |