Class: ThisData::Configuration
- Inherits:
-
Object
- Object
- ThisData::Configuration
- Defined in:
- lib/this_data/configuration.rb
Constant Summary collapse
- JS_COOKIE_NAME =
ThisData’s JS library (optional) adds a cookie with this name
'__tdli'
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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/this_data/configuration.rb', line 52 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, expect_js_cookie: false }) end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
50 51 52 |
# File 'lib/this_data/configuration.rb', line 50 def defaults @defaults end |
Class Method Details
.config_option(name) ⇒ Object
Programatically create attr accessors for config_option
10 11 12 13 14 15 16 17 18 |
# File 'lib/this_data/configuration.rb', line 10 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
67 68 69 |
# File 'lib/this_data/configuration.rb', line 67 def [](key) read_value(key) end |
#[]=(key, value) ⇒ Object
71 72 73 |
# File 'lib/this_data/configuration.rb', line 71 def []=(key, value) set_value(key, value) end |