Module: ScopedChoices::Rails
- Defined in:
- lib/scoped_choices/rails.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/scoped_choices/rails.rb', line 4 def self.included(base) base.class_eval do def initialize_with_scoped_choices(*args, &block) initialize_without_scoped_choices(*args, &block) @scoped_choices = Hashie::Mash.new end alias :initialize_without_scoped_choices :initialize alias :initialize :initialize_with_scoped_choices end end |
Instance Method Details
#from_file_with_scope(name, scope) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/scoped_choices/rails.rb', line 16 def from_file_with_scope(name, scope) root = self.respond_to?(:root) ? self.root : Rails.root file = root + 'config' + name settings = ScopedChoices.load_settings(file, Rails.respond_to?(:env) ? Rails.env : RAILS_ENV) if scope scoped_settings = Hashie::Mash.new scoped_settings.send("#{scope}=", settings) settings = scoped_settings end @scoped_choices.update settings settings.each do |key, value| self.send("#{key}=", value) end end |