Module: DjMailer::Delayable
- Defined in:
- lib/dj_mailer.rb
Defined Under Namespace
Modules: Deliverable
Class Method Summary collapse
- .excluded_environments ⇒ Object
- .excluded_environments=(*environments) ⇒ Object
- .extended(base) ⇒ Object
Instance Method Summary collapse
- #enqueue_with_delayed_job(method, *args) ⇒ Object
- #environment_excluded? ⇒ Boolean
- #method_missing_with_delay(method, *args) ⇒ Object
Class Method Details
.excluded_environments ⇒ Object
39 40 41 |
# File 'lib/dj_mailer.rb', line 39 def self.excluded_environments @@excluded_environments ||= [] end |
.excluded_environments=(*environments) ⇒ Object
35 36 37 |
# File 'lib/dj_mailer.rb', line 35 def self.excluded_environments=(*environments) @@excluded_environments = environments && environments.flatten.collect! { |env| env.to_sym } end |
.extended(base) ⇒ Object
11 12 13 14 15 |
# File 'lib/dj_mailer.rb', line 11 def self.extended(base) class << base alias_method_chain :method_missing, :delay end end |
Instance Method Details
#enqueue_with_delayed_job(method, *args) ⇒ Object
25 26 27 28 29 |
# File 'lib/dj_mailer.rb', line 25 def enqueue_with_delayed_job(method, *args) delay.send(method, *args).tap do |dj_instance| dj_instance.extend Deliverable end end |
#environment_excluded? ⇒ Boolean
31 32 33 |
# File 'lib/dj_mailer.rb', line 31 def environment_excluded? defined?(Rails) && ::DjMailer::Delayable.excluded_environments.include?(Rails.env.to_sym) end |
#method_missing_with_delay(method, *args) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/dj_mailer.rb', line 17 def method_missing_with_delay(method, *args) if !environment_excluded? && respond_to?(method) and !caller.grep(/delayed_job/).present? enqueue_with_delayed_job(method, *args) else method_missing_without_delay(method, *args) end end |