Class: SimpleModel::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_model/config.rb

Constant Summary collapse

DEFAULTS =
{
  :initialize_defaults  => false,
  :attributes_store     => (RUBY_VERSION >= "2.2" ? :symbol : :string) # OPTIONS => :string, :symbol, :indifferent
}.freeze
ATTRIBUTE_STORES =
{
  :symbol => :to_sym,
  :string => :to_s,
  :indifferent => :to_s
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



19
20
21
22
23
# File 'lib/simple_model/config.rb', line 19

def initialize
  DEFAULTS.each do |setting, val|
    self.send("#{setting}=", val)
  end
end

Instance Attribute Details

#attributes_storeObject

Returns the value of attribute attributes_store.



17
18
19
# File 'lib/simple_model/config.rb', line 17

def attributes_store
  @attributes_store
end

#initialize_defaultsObject Also known as: initialize_defaults?

Returns the value of attribute initialize_defaults.



14
15
16
# File 'lib/simple_model/config.rb', line 14

def initialize_defaults
  @initialize_defaults
end

Instance Method Details

#attibutes_store_castObject



25
26
27
# File 'lib/simple_model/config.rb', line 25

def attibutes_store_cast
  ATTRIBUTE_STORES[attributes_store]
end