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.
15 16 17 18 19 20 |
# File 'lib/dispatch-rider/message.rb', line 15 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.
11 12 13 |
# File 'lib/dispatch-rider/message.rb', line 11 def body @body end |
#subject ⇒ Object
Returns the value of attribute subject.
11 12 13 |
# File 'lib/dispatch-rider/message.rb', line 11 def subject @subject end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 33 34 |
# File 'lib/dispatch-rider/message.rb', line 30 def ==(other) return false unless other.respond_to? :attributes attributes == other.attributes end |
#as_json ⇒ Object
26 27 28 |
# File 'lib/dispatch-rider/message.rb', line 26 def as_json(*) attributes end |
#attributes ⇒ Object
22 23 24 |
# File 'lib/dispatch-rider/message.rb', line 22 def attributes { subject: subject, body: body } end |