class ActivePivot::Activity

Attributes

remote_activity[RW]

Public Class Methods

new(remote_activity) click to toggle source
# File lib/active_pivot/activity.rb, line 5
def initialize(remote_activity)
  self.remote_activity = remote_activity
end

Public Instance Methods

store() click to toggle source
# File lib/active_pivot/activity.rb, line 9
def store
  story.update_attribute(:started_at, updated_at) if store?
end

Private Instance Methods

change() click to toggle source
# File lib/active_pivot/activity.rb, line 55
def change
  @change ||= remote_activity.changes.detect do |change|
    change['new_values'] && change['new_values']['current_state']
  end
end
current_state() click to toggle source
# File lib/active_pivot/activity.rb, line 39
def current_state
  new_values.present? ? new_values['current_state'] : 'unstarted'
end
kind() click to toggle source
# File lib/active_pivot/activity.rb, line 31
def kind
  @kind ||= primary_resource['kind']
end
new_values() click to toggle source
# File lib/active_pivot/activity.rb, line 51
def new_values
  change['new_values'] if change
end
primary_resource() click to toggle source
# File lib/active_pivot/activity.rb, line 47
def primary_resource
  remote_activity.primary_resources[0]
end
started?() click to toggle source
# File lib/active_pivot/activity.rb, line 27
def started?
  current_state.present? && current_state == 'started'
end
started_before?(updated_at) click to toggle source
# File lib/active_pivot/activity.rb, line 19
def started_before?(updated_at)
  story.started_at.nil? || story.started_at < updated_at
end
store?() click to toggle source
# File lib/active_pivot/activity.rb, line 15
def store?
  started? && started_before?(updated_at)
end
story() click to toggle source
# File lib/active_pivot/activity.rb, line 23
def story
  @story ||= ActivePivot::Story.find_by_pivotal_id(story_id)
end
story_id() click to toggle source
# File lib/active_pivot/activity.rb, line 35
def story_id
  @story_id ||= primary_resource['id']
end
updated_at() click to toggle source
# File lib/active_pivot/activity.rb, line 43
def updated_at
  @updated_at ||= new_values['updated_at']
end