Class: ThisData::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/this_data/configuration.rb

Constant Summary collapse

'__tdli'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#defaultsObject (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