Class: ActionMailer::Enqueable::Deferred
- Inherits:
-
Object
- Object
- ActionMailer::Enqueable::Deferred
- Defined in:
- lib/action_mailer/enqueable/deferred.rb
Defined Under Namespace
Classes: Invalid
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #arguments ⇒ Object
- #attributes ⇒ Object
- #encoded ⇒ Object
-
#initialize(params) ⇒ Deferred
constructor
A new instance of Deferred.
- #mail ⇒ Object
- #mailer_class ⇒ Object
- #mailer_name ⇒ Object
- #method_id ⇒ Object
- #to_json(options = {}) ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(params) ⇒ Deferred
Returns a new instance of Deferred.
25 26 27 28 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 25 def initialize(params) @params = params @params.symbolize_keys! end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
23 24 25 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 23 def errors @errors end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
23 24 25 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 23 def params @params end |
Class Method Details
.encoder ⇒ Object
19 20 21 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 19 def self.encoder RecordEncoder end |
.from_hash(params) ⇒ Object
13 14 15 16 17 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 13 def self.from_hash(params) decoded = encoder.decode(params) new(decoded) end |
.from_json(params) ⇒ Object
9 10 11 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 9 def self.from_json(params) from_hash(ActiveSupport::JSON.decode(params)) end |
Instance Method Details
#==(other) ⇒ Object
75 76 77 78 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 75 def ==(other) other.respond_to?(:params) && other.params == params end |
#arguments ⇒ Object
46 47 48 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 46 def arguments params[:arguments] end |
#attributes ⇒ Object
50 51 52 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 50 def attributes { :mailer_name => mailer_name, :method_id => method_id, :arguments => arguments } end |
#encoded ⇒ Object
71 72 73 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 71 def encoded self.class.encoder.encode(params) end |
#mail ⇒ Object
30 31 32 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 30 def mail @mailer ||= mailer_class.send(method_id, *arguments).create end |
#mailer_class ⇒ Object
34 35 36 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 34 def mailer_class mailer_name.constantize end |
#mailer_name ⇒ Object
38 39 40 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 38 def mailer_name params[:mailer_name] end |
#method_id ⇒ Object
42 43 44 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 42 def method_id params[:method_id] end |
#to_json(options = {}) ⇒ Object
67 68 69 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 67 def to_json( = {}) ActiveSupport::JSON.encode(encoded) end |
#valid? ⇒ Boolean
58 59 60 61 62 63 64 65 |
# File 'lib/action_mailer/enqueable/deferred.rb', line 58 def valid? @errors = attributes.map do |name, value| "#{name} can't be nil" if value.nil? end @errors.compact! @errors.empty? end |