class EasySettings::Base

Public Class Methods

[](key) click to toggle source
# File lib/easy_settings/base.rb, line 19
def [](key)
  self.where(key: key).first.try(:value)
end
[]=(key, value) click to toggle source
# File lib/easy_settings/base.rb, line 23
def []=(key, value)
  record = self.where(key: key).first
  if record
    record.update(value: value)
  else
    self.create(key: key, value: value)
  end
end
method_missing(method, *args) click to toggle source
# File lib/easy_settings/base.rb, line 8
def method_missing(method, *args)
  method_name = method.to_s
  if method_name[-1] == '='
    key = method_name[0...-1]
    value = args.first
    self[key]=value
  else
    self[method_name]
  end
end