Module: Feedable::ActsAsFeedable::InstanceMethods
- Defined in:
- lib/feedable/acts_as_feedable.rb
Instance Attribute Summary collapse
-
#feed_initiator_id ⇒ Object
Returns the value of attribute feed_initiator_id.
Instance Method Summary collapse
- #acts_like_feedable? ⇒ Boolean
-
#add_custom_feed(action, initiator, options = {}) ⇒ Object
Adds a custom feed for this object with the given
action
andinitiator
. - #aggregate_action ⇒ Object
- #aggregating? ⇒ Boolean
- #delegate_action_for(action) ⇒ Object
- #delegating? ⇒ Boolean
- #destroy_with_feed(user, *args) ⇒ Object
-
#save_with_feed(user, *args) ⇒ Object
ActiveRecord Wrappers with initiators.
- #save_with_feed!(user, *args) ⇒ Object
-
#scoping_object ⇒ Object
Returns the scoping object for this object.
-
#scoping_object? ⇒ Boolean
Returns true if this object is a scoping object.
- #update_attributes_with_feed(user, *args) ⇒ Object
- #update_attributes_with_feed!(user, *args) ⇒ Object
- #with_feed(user) ⇒ Object
Instance Attribute Details
#feed_initiator_id ⇒ Object
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
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, = {}) feed = Feed.new(:initiator => initiator, :action => action, :scoping_object => scoping_object, :feedable => self, :target_name => target_name) feed. = [:map] if [:map] feed.save! end |
#aggregate_action ⇒ Object
132 133 134 |
# File 'lib/feedable/acts_as_feedable.rb', line 132 def aggregate_action self.[:aggregate][:action] end |
#aggregating? ⇒ Boolean
128 129 130 |
# File 'lib/feedable/acts_as_feedable.rb', line 128 def aggregating? self.[:aggregate][:action].present? && self.[: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.[:delegate][:actions][action.to_sym] || action.to_s end |
#delegating? ⇒ Boolean
120 121 122 |
# File 'lib/feedable/acts_as_feedable.rb', line 120 def delegating? self.[:delegate][:actions].present? && self.[: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_object ⇒ Object
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
116 117 118 |
# File 'lib/feedable/acts_as_feedable.rb', line 116 def scoping_object? self.[: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 |