Class: ThisData::Configuration
- Inherits:
-
Object
- Object
- ThisData::Configuration
- Defined in:
- lib/this_data/configuration.rb
Instance Attribute Summary collapse
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
Class Method Summary collapse
-
.config_option(name) ⇒ Object
Programatically create attr accessors for config_option.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/this_data/configuration.rb', line 44 def initialize @config_values = {} # set default attribute values @defaults = OpenStruct.new({ async: true, user_method: :current_user, user_id_method: :id, user_name_method: :name, user_email_method: :email, user_mobile_method: :mobile }) end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
42 43 44 |
# File 'lib/this_data/configuration.rb', line 42 def defaults @defaults end |
Class Method Details
.config_option(name) ⇒ Object
Programatically create attr accessors for config_option
7 8 9 10 11 12 13 14 15 |
# File 'lib/this_data/configuration.rb', line 7 def self.config_option(name) define_method(name) do read_value(name) end define_method("#{name}=") do |value| set_value(name, value) end end |
Instance Method Details
#[](key) ⇒ Object
58 59 60 |
# File 'lib/this_data/configuration.rb', line 58 def [](key) read_value(key) end |
#[]=(key, value) ⇒ Object
62 63 64 |
# File 'lib/this_data/configuration.rb', line 62 def []=(key, value) set_value(key, value) end |