Class: CaptainConfig::Service::DSL
- Inherits:
-
ActiveSupport::ProxyObject
- Object
- ActiveSupport::ProxyObject
- CaptainConfig::Service::DSL
- Defined in:
- lib/captain_config/service/dsl.rb
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
-
#initialize(service) ⇒ DSL
constructor
A new instance of DSL.
- #method_missing(key, *args) ⇒ Object
Constructor Details
#initialize(service) ⇒ DSL
Returns a new instance of DSL.
6 7 8 |
# File 'lib/captain_config/service/dsl.rb', line 6 def initialize(service) @service = service end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/captain_config/service/dsl.rb', line 10 def method_missing(key, *args) type, opts, *_rest = args model = case type when :boolean ::CaptainConfig::BooleanConfig when :integer ::CaptainConfig::IntegerConfig when :string ::CaptainConfig::StringConfig else raise ArgumentError.new("Unrecognized type: #{type.inspect}") end entry = ::CaptainConfig::ConfiguredEntry.new(key, model) if opts opts.each do |opt, value| entry.send("#{opt}=", value) end end service << entry end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
4 5 6 |
# File 'lib/captain_config/service/dsl.rb', line 4 def service @service end |