Class: ConvenientService::Core::Entities::Config::Commands::BuildEntityFromConfigOption
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Core::Entities::Config::Commands::BuildEntityFromConfigOption
- Defined in:
- lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb
Overview
Instance Attribute Summary collapse
- #base_entity ⇒ Object readonly
- #config ⇒ ConvenientService::Config::Entities::Option readonly
- #detail_keys ⇒ Object readonly
- #option ⇒ Object readonly
Instance Method Summary collapse
-
#call ⇒ Object
Can be any type.
- #initialize(base_entity:, option:, detail_keys:) ⇒ void constructor
Methods inherited from Support::Command
Constructor Details
#initialize(base_entity:, option:, detail_keys:) ⇒ void
38 39 40 41 42 |
# File 'lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb', line 38 def initialize(base_entity:, option:, detail_keys:) @base_entity = base_entity @option = option @detail_keys = detail_keys end |
Instance Attribute Details
#base_entity ⇒ Object (readonly)
18 19 20 |
# File 'lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb', line 18 def base_entity @base_entity end |
#config ⇒ ConvenientService::Config::Entities::Option (readonly)
24 |
# File 'lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb', line 24 attr_reader :option |
#detail_keys ⇒ Object (readonly)
30 31 32 |
# File 'lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb', line 30 def detail_keys @detail_keys end |
#option ⇒ Object (readonly)
24 25 26 |
# File 'lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb', line 24 def option @option end |
Instance Method Details
#call ⇒ Object
Returns Can be any type.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb', line 47 def call return base_entity unless option return base_entity if option.data.empty? return base_entity if detail_keys.empty? data_values = option.data.slice(*detail_keys) return base_entity if data_values.empty? base_entity.with(**data_values) end |