Module: Config::Factory::AbstractFactory
- Defined in:
- lib/config/factory/abstract_factory.rb
Instance Attribute Summary collapse
-
#product_key ⇒ Object
readonly
Returns the value of attribute product_key.
Instance Method Summary collapse
Instance Attribute Details
#product_key ⇒ Object (readonly)
Returns the value of attribute product_key.
8 9 10 |
# File 'lib/config/factory/abstract_factory.rb', line 8 def product_key @product_key end |
Instance Method Details
#build_from(arg_hash) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/config/factory/abstract_factory.rb', line 23 def build_from(arg_hash) args = deep_symbolize_keys(arg_hash) key_value = args.delete(product_key) product_class = products[key_value] fail ArgumentError, "No #{name} product class found for #{product_key}: #{key_value}" unless product_class product_class.new(args) end |
#for_environment(env, key) ⇒ Object
18 19 20 21 |
# File 'lib/config/factory/abstract_factory.rb', line 18 def for_environment(env, key) arg_hash = env.args_for(key) build_from(arg_hash) end |
#key(k) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/config/factory/abstract_factory.rb', line 10 def key(k) @product_key = k registry = products define_singleton_method(k) do |v| registry[v] = self end end |