Class: DispatchRider::Message
- Inherits:
-
Object
- Object
- DispatchRider::Message
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/dispatch-rider/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_json ⇒ Object
- #attributes ⇒ Object
-
#initialize(options) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(options) ⇒ Message
Returns a new instance of Message.
13 14 15 16 17 18 |
# File 'lib/dispatch-rider/message.rb', line 13 def initialize() attrs = .symbolize_keys @subject = attrs[:subject] @body = attrs[:body] || {} raise RecordInvalid.new(self, errors.) unless valid? end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/dispatch-rider/message.rb', line 9 def body @body end |
#subject ⇒ Object
Returns the value of attribute subject.
9 10 11 |
# File 'lib/dispatch-rider/message.rb', line 9 def subject @subject end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 |
# File 'lib/dispatch-rider/message.rb', line 28 def ==(other) return false unless other.respond_to? :attributes attributes == other.attributes end |
#as_json ⇒ Object
24 25 26 |
# File 'lib/dispatch-rider/message.rb', line 24 def as_json(*) attributes end |
#attributes ⇒ Object
20 21 22 |
# File 'lib/dispatch-rider/message.rb', line 20 def attributes { subject: subject, body: body } end |