Module: EffectiveGem::ClassMethods
- Defined in:
- lib/effective_resources/effective_gem.rb
Instance Method Summary collapse
- #config(namespace = nil) ⇒ Object
- #deliver_method ⇒ Object
- #mailer_admin ⇒ Object
- #mailer_layout ⇒ Object
- #mailer_sender ⇒ Object
- #mailer_subject ⇒ Object
-
#parent_mailer_class ⇒ Object
Mailer Settings These methods are intended to flow through to the default EffectiveResources settings.
- #send_email(email, *args) ⇒ Object
- #setup(namespace = nil) {|config(namespace)| ... } ⇒ Object
Instance Method Details
#config(namespace = nil) ⇒ Object
27 28 29 30 |
# File 'lib/effective_resources/effective_gem.rb', line 27 def config(namespace = nil) namespace ||= Tenant.current if defined?(Tenant) @config.dig(namespace) || @config.dig(:effective) end |
#deliver_method ⇒ Object
59 60 61 |
# File 'lib/effective_resources/effective_gem.rb', line 59 def deliver_method config[:deliver_method].presence || EffectiveResources.deliver_method end |
#mailer_admin ⇒ Object
71 72 73 |
# File 'lib/effective_resources/effective_gem.rb', line 71 def mailer_admin config[:mailer_admin].presence || EffectiveResources.mailer_admin end |
#mailer_layout ⇒ Object
63 64 65 |
# File 'lib/effective_resources/effective_gem.rb', line 63 def mailer_layout config[:mailer_layout].presence || EffectiveResources.mailer_layout end |
#mailer_sender ⇒ Object
67 68 69 |
# File 'lib/effective_resources/effective_gem.rb', line 67 def mailer_sender config[:mailer_sender].presence || EffectiveResources.mailer_sender end |
#mailer_subject ⇒ Object
75 76 77 |
# File 'lib/effective_resources/effective_gem.rb', line 75 def mailer_subject config[:mailer_subject].presence || EffectiveResources.mailer_subject end |
#parent_mailer_class ⇒ Object
Mailer Settings These methods are intended to flow through to the default EffectiveResources settings
55 56 57 |
# File 'lib/effective_resources/effective_gem.rb', line 55 def parent_mailer_class config[:parent_mailer].presence&.constantize || EffectiveResources.parent_mailer_class end |
#send_email(email, *args) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/effective_resources/effective_gem.rb', line 79 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(deliver_method) end |
#setup(namespace = nil) {|config(namespace)| ... } ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/effective_resources/effective_gem.rb', line 32 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 |