Class: ResourceSubscriber::Message
- Inherits:
-
Object
- Object
- ResourceSubscriber::Message
- Includes:
- ActiveModel::Serializers::JSON
- Defined in:
- lib/resource_subscriber/message.rb
Instance Attribute Summary collapse
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#resource_type ⇒ Object
Returns the value of attribute resource_type.
Instance Method Summary collapse
- #attributes ⇒ Object
- #attributes=(hash) ⇒ Object
-
#initialize(resource) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(resource) ⇒ Message
Returns a new instance of Message.
7 8 9 10 11 |
# File 'lib/resource_subscriber/message.rb', line 7 def initialize(resource) @resource_type = resource.class.base_class.name @changes = resource.changes.blank? ? resource.previous_changes : resource.changes @resource = resource.attributes end |
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
5 6 7 |
# File 'lib/resource_subscriber/message.rb', line 5 def changes @changes end |
#resource ⇒ Object
Returns the value of attribute resource.
5 6 7 |
# File 'lib/resource_subscriber/message.rb', line 5 def resource @resource end |
#resource_type ⇒ Object
Returns the value of attribute resource_type.
5 6 7 |
# File 'lib/resource_subscriber/message.rb', line 5 def resource_type @resource_type end |
Instance Method Details
#attributes ⇒ Object
19 20 21 |
# File 'lib/resource_subscriber/message.rb', line 19 def attributes instance_values end |
#attributes=(hash) ⇒ Object
13 14 15 16 17 |
# File 'lib/resource_subscriber/message.rb', line 13 def attributes=(hash) hash.each do |key, value| send("#{key}=", value) end end |