Class: MadFlatter::Service
- Inherits:
-
Object
- Object
- MadFlatter::Service
- Includes:
- HashLoadable, Optionable
- Defined in:
- lib/mad_flatter/service.rb
Overview
This class provides functionality to load and flatten a Hash. Default options passed to the constructor may be overridden with options passed to the #execute method.
Constant Summary
Constants included from OptionsValidatable
Constants included from NamespaceOptionable
NamespaceOptionable::OPTION_NAMESPACE, NamespaceOptionable::OPTION_NAMESPACE_DEFAULT
Constants included from MetadataOptionable
MetadataOptionable::OPTION_METADATA, MetadataOptionable::OPTION_METADATA_DEFAULT, MetadataOptionable::OPTION_METADATA_EXCLUDE, MetadataOptionable::OPTION_METADATA_INCLUDE, MetadataOptionable::OPTION_METADATA_VALUES
Instance Method Summary collapse
- #execute(hash:, options: nil) ⇒ Object
-
#initialize(options: nil) ⇒ Service
constructor
A new instance of Service.
Methods included from Optionable
Methods included from OptionsValidatable
#validate_option_keys!, #validate_option_metadata!, #validate_option_namespace!, #validate_options!, #validate_options_type!
Methods included from HashInformable
Constructor Details
#initialize(options: nil) ⇒ Service
Returns a new instance of Service.
14 15 16 17 18 19 20 21 22 |
# File 'lib/mad_flatter/service.rb', line 14 def initialize(options: nil) ||= {} # Accept whatever options are sent, but make sure # we have defaults set up. #with_defaults # will merge options into OptionsDefaultable::DEFAULT_OPTIONS # so we have defaults for any options not passed. self. = Options.with_defaults end |
Instance Method Details
#execute(hash:, options: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mad_flatter/service.rb', line 24 def execute(hash:, options: nil) ||= {} # Merge options received into the default options passed through # the constructor. Options received here, will override any options # passed to the constructor, allowing us to retain defaut options # while loading, and also provide option overrides as needed. = Options.with_defaults(, defaults: self.) load_hash(hash, ) end |