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_froms ⇒ 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
29 30 31 32 |
# File 'lib/effective_resources/effective_gem.rb', line 29 def config(namespace = nil) namespace ||= Tenant.current if defined?(Tenant) (@config[namespace] if namespace) || @config[:effective] end |
#deliver_method ⇒ Object
61 62 63 |
# File 'lib/effective_resources/effective_gem.rb', line 61 def deliver_method config[:deliver_method].presence || EffectiveResources.deliver_method end |
#mailer_admin ⇒ Object
77 78 79 |
# File 'lib/effective_resources/effective_gem.rb', line 77 def mailer_admin config[:mailer_admin].presence || EffectiveResources.mailer_admin end |
#mailer_froms ⇒ Object
73 74 75 |
# File 'lib/effective_resources/effective_gem.rb', line 73 def mailer_froms config[:mailer_froms].presence || EffectiveResources.mailer_froms end |
#mailer_layout ⇒ Object
65 66 67 |
# File 'lib/effective_resources/effective_gem.rb', line 65 def mailer_layout config[:mailer_layout].presence || EffectiveResources.mailer_layout end |
#mailer_sender ⇒ Object
69 70 71 |
# File 'lib/effective_resources/effective_gem.rb', line 69 def mailer_sender config[:mailer_sender].presence || EffectiveResources.mailer_sender end |
#mailer_subject ⇒ Object
81 82 83 |
# File 'lib/effective_resources/effective_gem.rb', line 81 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
57 58 59 |
# File 'lib/effective_resources/effective_gem.rb', line 57 def parent_mailer_class config[:parent_mailer].presence&.constantize || EffectiveResources.parent_mailer_class end |
#send_email(email, *args) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/effective_resources/effective_gem.rb', line 85 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/effective_resources/effective_gem.rb', line 34 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 |