Sha256: c367250358948779b0165e1e2bfecfb5a4e4785d023640863e567040566dd976
Contents?: true
Size: 1.33 KB
Versions: 20
Compression:
Stored size: 1.33 KB
Contents
# Effective Engine concern module EffectiveGem extend ActiveSupport::Concern included do raise("expected self.config_keys method") unless respond_to?(:config_keys) config_keys.each do |key| self.singleton_class.define_method(key) { config()[key] } self.singleton_class.define_method("#{key}=") { |value| config()[key] = value } end end module ClassMethods def config(namespace = nil) namespace ||= Tenant.current if defined?(Tenant) @config.dig(namespace) || @config.dig(:effective) end def setup(namespace = nil, &block) @config ||= ActiveSupport::OrderedOptions.new namespace ||= Tenant.current if defined?(Tenant) namespace ||= :effective @config[namespace] ||= ActiveSupport::OrderedOptions.new yield(config(namespace)) if(unsupported = (config(namespace).keys - config_keys)).present? if unsupported.include?(:authorization_method) raise("config.authorization_method has been removed. This gem will call EffectiveResources.authorization_method instead. Please double check the config.authorization_method setting in config/initializers/effective_resources.rb and remove it from this file.") end raise("unsupported config keys: #{unsupported}\n supported keys: #{config_keys}") end true end end end
Version data entries
20 entries across 20 versions & 1 rubygems