17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/choices/rails.rb', line 17
def from_file(name)
root = self.respond_to?(:root) ? self.root : Rails.root
file = root + 'config' + name
settings = Choices.load_settings(file, Rails.respond_to?(:env) ? Rails.env : RAILS_ENV)
@choices.update settings
settings.each do |key, value|
old_value = self.respond_to?(key) ? self.send(key) : nil
if "Rails::OrderedOptions" == old_value.class.name
old_value = old_value.inject({}) {|h,(k,v)| h[k]=v; h }
end
if Hash === value and Hash === old_value
value = Hashie::Mash.new(old_value).update value
end
self.send("#{key}=", value)
end
end
|