Module: Auth::Configuration::Keys
- Included in:
- Behavior::Base::Configuration, Auth::Configuration
- Defined in:
- lib/auth/configuration/keys.rb
Overview
When included by a configuration object, the Keys module will override #attr_reader, #attr_writer and #attr_accessor to add configuration keys for each. A #to_hash instance method is generated which will this object into a Hash containing only the registered keys.
Class Method Summary collapse
Instance Method Summary collapse
- #configuration_keys ⇒ Object
-
#to_hash ⇒ Object
Returns this configuration as a Hash.
Class Method Details
.included(base) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/auth/configuration/keys.rb', line 20 def self.included(base) base.class_eval do class << self def configuration_keys @configuration_keys ||= [] end def add_configuration_key(*keys) configuration_keys.concat keys.flatten end def attr_reader(*args) #:nodoc: add_configuration_key(*args) super end def attr_writer(*args) #:nodoc: add_configuration_key(*args) super end def attr_accessor(*args) #:nodoc: add_configuration_key(*args) super end end end end |
Instance Method Details
#configuration_keys ⇒ Object
16 17 18 |
# File 'lib/auth/configuration/keys.rb', line 16 def configuration_keys self.class.configuration_keys end |
#to_hash ⇒ Object
Returns this configuration as a Hash
9 10 11 12 13 14 |
# File 'lib/auth/configuration/keys.rb', line 9 def to_hash configuration_keys.inject({}) do |hash, key| hash[key] = send(key) hash end end |