Class: ActiveHistory::Action
- Inherits:
-
Object
- Object
- ActiveHistory::Action
- Defined in:
- lib/activehistory/action.rb
Instance Attribute Summary collapse
-
#diff ⇒ Object
Returns the value of attribute diff.
-
#event_id ⇒ Object
Returns the value of attribute event_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#subject_id ⇒ Object
Returns the value of attribute subject_id.
-
#subject_type ⇒ Object
Returns the value of attribute subject_type.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(attrs) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(attrs) ⇒ Action
Returns a new instance of Action.
5 6 7 8 9 10 |
# File 'lib/activehistory/action.rb', line 5 def initialize(attrs) attrs.each do |k,v| self.send("#{k}=", v) end self.diff ||= {} end |
Instance Attribute Details
#diff ⇒ Object
Returns the value of attribute diff.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def diff @diff end |
#event_id ⇒ Object
Returns the value of attribute event_id.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def event_id @event_id end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def id @id end |
#subject_id ⇒ Object
Returns the value of attribute subject_id.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def subject_id @subject_id end |
#subject_type ⇒ Object
Returns the value of attribute subject_type.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def subject_type @subject_type end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/activehistory/action.rb', line 3 def type @type end |
Instance Method Details
#as_json ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/activehistory/action.rb', line 12 def as_json { diff: diff.as_json, subject_type: subject_type, subject_id: subject_id, timestamp: .iso8601(3), type: type, event_id: event_id, id: id }.select { |k, v| !v.nil? } end |