Module: EffectiveGem::ClassMethods
- Defined in:
- lib/effective_resources/effective_gem.rb
Instance Method Summary collapse
- #config(namespace = nil) ⇒ Object
-
#send_email(email, *args) ⇒ Object
This is included into every gem The gem may not have a mailer or use effective email templates.
- #setup(namespace = nil) {|config(namespace)| ... } ⇒ Object
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 |
#send_email(email, *args) ⇒ Object
This is included into every gem The gem may not have a mailer or use effective email templates
44 45 46 47 48 49 |
# File 'lib/effective_resources/effective_gem.rb', line 44 def send_email(email, *args) raise('gem does not respond to mailer_class') unless respond_to?(:mailer_class) raise('expected args to be an Array') unless args.kind_of?(Array) mailer_class.send(email, *args).send(EffectiveResources.deliver_method) end |
#setup(namespace = nil) {|config(namespace)| ... } ⇒ Object
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 |