Class: ResourceSubscriber::Message

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON
Defined in:
lib/resource_subscriber/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#changesObject

Returns the value of attribute changes.



5
6
7
# File 'lib/resource_subscriber/message.rb', line 5

def changes
  @changes
end

#resourceObject

Returns the value of attribute resource.



5
6
7
# File 'lib/resource_subscriber/message.rb', line 5

def resource
  @resource
end

#resource_typeObject

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

#attributesObject



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