Class: ActivityStream::Activity

Inherits:
LogicalModel
  • Object
show all
Defined in:
app/models/activity_stream/activity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cached_objectObject

Returns the value of attribute cached_object.



41
42
43
# File 'app/models/activity_stream/activity.rb', line 41

def cached_object
  @cached_object
end

#cached_targetObject

Returns the value of attribute cached_target.



54
55
56
# File 'app/models/activity_stream/activity.rb', line 54

def cached_target
  @cached_target
end

Instance Method Details

#json_rootObject



37
38
39
# File 'app/models/activity_stream/activity.rb', line 37

def json_root
  'activity'
end

#local?Boolean

Identifies activity as local to your app or not.

To identify your app you should define constant: ActivityStream::LOCAL_APP_NAME

Returns:



33
34
35
# File 'app/models/activity_stream/activity.rb', line 33

def local?
  defined?(LOCAL_APP_NAME) && (generator == LOCAL_APP_NAME)
end

#local_deleted_object?Boolean

Returns:



50
51
52
# File 'app/models/activity_stream/activity.rb', line 50

def local_deleted_object?
  local? && object.nil?
end

#objectObject



42
43
44
45
46
47
48
# File 'app/models/activity_stream/activity.rb', line 42

def object
  if !cached_object.present? && local?
    klass = self.object_type.camelize.constantize
    self.cached_object = klass.find(object_id) if klass.exists?(object_id)
  end
  cached_object
end

#targetObject



55
56
57
58
59
60
61
# File 'app/models/activity_stream/activity.rb', line 55

def target
  if !cached_target.present? && local?
    klass = target_type.camelize.constantize
    self.cached_target = klass.find(target_id) if klass.exists?(target_id)
  end
  cached_target
end