Class: Whenauser::MiddlewareConfigurator
- Inherits:
-
Object
- Object
- Whenauser::MiddlewareConfigurator
- Defined in:
- lib/whenauser/railtie.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #configure(&block) ⇒ Object
-
#initialize ⇒ MiddlewareConfigurator
constructor
A new instance of MiddlewareConfigurator.
- #method_missing(mid, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ MiddlewareConfigurator
Returns a new instance of MiddlewareConfigurator.
47 48 49 |
# File 'lib/whenauser/railtie.rb', line 47 def initialize @configuration = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mid, *args, &block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/whenauser/railtie.rb', line 55 def method_missing(mid, *args, &block) mname = mid.id2name if block_given? @configuration[mname.to_sym] = *block else if args.size == 1 @configuration[mname.to_sym] = args.first else @configuration[mname.to_sym] = args end end end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
39 40 41 |
# File 'lib/whenauser/railtie.rb', line 39 def configuration @configuration end |
Class Method Details
.apply(&block) ⇒ Object
41 42 43 44 45 |
# File 'lib/whenauser/railtie.rb', line 41 def self.apply(&block) x = new x.configure(&block) if block_given? x end |
Instance Method Details
#configure(&block) ⇒ Object
51 52 53 |
# File 'lib/whenauser/railtie.rb', line 51 def configure(&block) instance_eval &block end |