module Choices::Rails

Public Class Methods

included(base) click to toggle source
# File lib/choices/rails.rb, line 4
def self.included(base)
  base.class_eval do
    def initialize_with_choices(*args, &block)
      initialize_without_choices(*args, &block)
      @choices = Hashie::Mash.new
    end
    
    alias :initialize_without_choices :initialize
    alias :initialize :initialize_with_choices
  end
end

Public Instance Methods

from_file(name) click to toggle source
# File lib/choices/rails.rb, line 16
def from_file(name)
  root = self.respond_to?(:root) ? self.root : Rails.root
  file = root + 'config' + name
  
  settings = Choices.load_settings(file, RAILS_ENV)
  @choices.update settings
  
  settings.each do |key, value|
    self.send("#{key}=", value)
  end
end
initialize_with_choices(*args, &block) click to toggle source
# File lib/choices/rails.rb, line 6
def initialize_with_choices(*args, &block)
  initialize_without_choices(*args, &block)
  @choices = Hashie::Mash.new
end