Module: EffectiveGem::ClassMethods

Defined in:
lib/effective_resources/effective_gem.rb

Instance Method Summary collapse

Instance Method Details

#config(namespace = nil) ⇒ Object



16
17
18
19
# File 'lib/effective_resources/effective_gem.rb', line 16

def config(namespace = nil)
  namespace ||= Tenant.current if defined?(Tenant)
  @config.dig(namespace) || @config.dig(:effective)
end

#setup(namespace = nil) {|config(namespace)| ... } ⇒ Object

Yields:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/effective_resources/effective_gem.rb', line 21

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