Class: CottonTail::Configuration
- Inherits:
-
Object
- Object
- CottonTail::Configuration
- Defined in:
- lib/cotton_tail/configuration.rb
Overview
Configuration options
Instance Attribute Summary collapse
-
#connection_args ⇒ Object
Returns the value of attribute connection_args.
Instance Method Summary collapse
-
#initialize(middleware: nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(method_id, *arguments, &block) ⇒ Object
-
#middleware ⇒ Object
Modify or retrieve the application middleware stack.
- #respond_to_missing?(method_id, include_private = false) ⇒ Boolean
Constructor Details
#initialize(middleware: nil) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 |
# File 'lib/cotton_tail/configuration.rb', line 10 def initialize(middleware: nil) @connection_args = nil @middleware = middleware @user_configs = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *arguments, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/cotton_tail/configuration.rb', line 37 def method_missing(method_id, *arguments, &block) if user_config? method_id @user_configs[method_id] elsif setter?(method_id) && arguments.length == 1 @user_configs[getter_name(method_id)] = arguments.first else super end end |
Instance Attribute Details
#connection_args ⇒ Object
Returns the value of attribute connection_args.
8 9 10 |
# File 'lib/cotton_tail/configuration.rb', line 8 def connection_args @connection_args end |
Instance Method Details
#middleware ⇒ Object
Modify or retrieve the application middleware stack.
28 29 30 31 32 33 34 35 |
# File 'lib/cotton_tail/configuration.rb', line 28 def middleware return @middleware unless block_given? @middleware = ::Middleware::Builder.new do |b| b.use @middleware if @middleware yield b end end |
#respond_to_missing?(method_id, include_private = false) ⇒ Boolean
47 48 49 |
# File 'lib/cotton_tail/configuration.rb', line 47 def respond_to_missing?(method_id, include_private = false) user_config?(method_id) || super end |