lib/strong_actions/config.rb in strong_actions-0.0.3 vs lib/strong_actions/config.rb in strong_actions-0.0.4

- old
+ new

@@ -3,43 +3,42 @@ module StrongActions class Config include Singleton def initialize - @config_files = ['config/acl.yml'] - load_config_files + @config_files ||= ['config/acl.yml'] end def config_files @config_files end def config_files=(files) - config_files = files - load_config_files + @config_files = ([] << files).flatten end def roles - load_config_files if Rails.env.development? - @acl.keys + definitions.keys end def role_definition(role) - load_config_files if Rails.env.development? - @acl[role] + definitions[role] end private - def load_config_files - @acl = {} - config_files.each do |config_file| - yml = YAML.load_file(config_file) - yml.each do |role, values| - raise "role #{role} is already defined." if @acl.has_key?(role) - @acl[role] = values + def definitions + if @acl.nil? or Rails.env.development? + @acl = {} + config_files.each do |config_file| + yml = YAML.load_file(config_file) + yml.each do |role, values| + raise "role #{role} is already defined." if @acl.has_key?(role) + @acl[role] = values + end end end + @acl end end end \ No newline at end of file