Class: BusinessPipeline::Config
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- BusinessPipeline::Config
- Defined in:
- lib/business_pipeline/config.rb
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize(hash = nil, &block) ⇒ Config
constructor
A new instance of Config.
-
#method_missing(meth, *args, &block) ⇒ Object
rubocop:disable Style/MissingRespondToMissing.
Constructor Details
#initialize(hash = nil, &block) ⇒ Config
Returns a new instance of Config.
7 8 9 10 |
# File 'lib/business_pipeline/config.rb', line 7 def initialize(hash = nil, &block) super(hash) instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
rubocop:disable Style/MissingRespondToMissing
22 23 24 25 26 27 28 |
# File 'lib/business_pipeline/config.rb', line 22 def method_missing(meth, *args, &block) if args.size.zero? || meth.to_s.end_with?('=') super else self[meth] = args.first end end |
Instance Method Details
#fetch(key) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/business_pipeline/config.rb', line 12 def fetch(key) value = self[key.to_sym] return value unless value.nil? return yield(key) if block_given? fail KeyError, key end |