Module: Feedable::ActsAsFeedable::InstanceMethods

Defined in:
lib/feedable/acts_as_feedable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#feed_initiator_idObject

Returns the value of attribute feed_initiator_id.



104
105
106
# File 'lib/feedable/acts_as_feedable.rb', line 104

def feed_initiator_id
  @feed_initiator_id
end

Instance Method Details

#acts_like_feedable?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/feedable/acts_as_feedable.rb', line 106

def acts_like_feedable?
  true
end

#add_custom_feed(action, initiator, options = {}) ⇒ Object

Adds a custom feed for this object with the given action and initiator



170
171
172
173
174
175
176
# File 'lib/feedable/acts_as_feedable.rb', line 170

def add_custom_feed(action, initiator, options = {})          
  feed = Feed.new(:initiator => initiator, :action => action, :scoping_object => scoping_object, :feedable => self, :target_name => target_name)

  feed.initial_instance_level_permission_map = options[:map] if options[:map]
  
  feed.save!
end

#aggregate_actionObject



132
133
134
# File 'lib/feedable/acts_as_feedable.rb', line 132

def aggregate_action
  self.feed_options[:aggregate][:action]
end

#aggregating?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/feedable/acts_as_feedable.rb', line 128

def aggregating?
  self.feed_options[:aggregate][:action].present? && self.feed_options[:aggregate][:references].present?
end

#delegate_action_for(action) ⇒ Object



124
125
126
# File 'lib/feedable/acts_as_feedable.rb', line 124

def delegate_action_for(action)
  self.feed_options[:delegate][:actions][action.to_sym] || action.to_s
end

#delegating?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/feedable/acts_as_feedable.rb', line 120

def delegating?
  self.feed_options[:delegate][:actions].present? && self.feed_options[:delegate][:references].present?
end

#destroy_with_feed(user, *args) ⇒ Object



157
158
159
160
# File 'lib/feedable/acts_as_feedable.rb', line 157

def destroy_with_feed(user, *args)
  self.feed_initiator_id = user.id
  return destroy(*args)
end

#save_with_feed(user, *args) ⇒ Object

ActiveRecord Wrappers with initiators



137
138
139
140
# File 'lib/feedable/acts_as_feedable.rb', line 137

def save_with_feed(user, *args)
  self.feed_initiator_id = user.id
  return save(*args)
end

#save_with_feed!(user, *args) ⇒ Object



142
143
144
145
# File 'lib/feedable/acts_as_feedable.rb', line 142

def save_with_feed!(user, *args)
  self.feed_initiator_id = user.id
  return save!(*args)
end

#scoping_objectObject

Returns the scoping object for this object



111
112
113
# File 'lib/feedable/acts_as_feedable.rb', line 111

def scoping_object
  scoping_ancestor || parent_feedable
end

#scoping_object?Boolean

Returns true if this object is a scoping object

Returns:

  • (Boolean)


116
117
118
# File 'lib/feedable/acts_as_feedable.rb', line 116

def scoping_object?
  self.feed_options[:scoping_object?] == true
end

#update_attributes_with_feed(user, *args) ⇒ Object



147
148
149
150
# File 'lib/feedable/acts_as_feedable.rb', line 147

def update_attributes_with_feed(user, *args)
  self.feed_initiator_id = user.id
  return update_attributes(*args)
end

#update_attributes_with_feed!(user, *args) ⇒ Object



152
153
154
155
# File 'lib/feedable/acts_as_feedable.rb', line 152

def update_attributes_with_feed!(user, *args)
  self.feed_initiator_id = user.id
  return update_attributes(*args)
end

#with_feed(user) ⇒ Object



162
163
164
165
# File 'lib/feedable/acts_as_feedable.rb', line 162

def with_feed(user)
  self.feed_initiator_id = user.id
  return self
end