class Olympic::Settings

Constants

DEFAULT_SETTINGS

Public Class Methods

new(settings = {}) click to toggle source
# File lib/olympic/settings.rb, line 35
def initialize(settings = {})
  @settings = DEFAULT_SETTINGS.clone.merge(settings)
  @klass = {}
end

Public Instance Methods

[](key) click to toggle source
# File lib/olympic/settings.rb, line 50
def [](key)
  @settings.fetch(key.to_s.to_sym)
end
[]=(key, value) click to toggle source
# File lib/olympic/settings.rb, line 45
def []=(key, value)
  @klass = {}
  @settings[key.to_s.to_sym] = value
end
build() { |self| ... } click to toggle source
# File lib/olympic/settings.rb, line 40
def build
  yield self
  self
end
class_for(name) click to toggle source
# File lib/olympic/settings.rb, line 54
def class_for(name)
  @klass.fetch(name) do
    @klass[name] = fetch(:"#{name}_class").constantize
  end
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/olympic/settings.rb, line 64
def method_missing(method, *args, &block)
  return super if args.length > 1 || block_given?

  method = method.to_s
  case method
  when /\?\z/, /\!\z/
    super
  when /\A(.*)\=\z/
    super unless args.length == 1
    self[$+] = args[0]
  else
    super unless args.length == 0
    self[method]
  end
end
rating_system() click to toggle source
# File lib/olympic/settings.rb, line 60
def rating_system
  Rating.for(rating)
end