Module: Lifestreamable::LifestreamableInstanceMethods
- Defined in:
- lib/lifestreamable/lifestreamable.rb
Instance Method Summary collapse
- #get_action_instead_of(action) ⇒ Object
- #get_payload ⇒ Object
- #lifestream_options ⇒ Object
- #lifestreamable?(action) ⇒ Boolean
Instance Method Details
#get_action_instead_of(action) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/lifestreamable/lifestreamable.rb', line 228 def get_action_instead_of(action) case action when :create :create when :update if test_instead_option([:create_instead_of_update]) :create elsif test_instead_option([:destroy_instead_of_update]) :destroy else :update end when :destroy if test_instead_option([:create_instead_of_destroy]) :create elsif test_instead_option([:destroy_instead_of_destroy]) :update else :destroy end else raise LifestreamableException.new("The action #{action.to_s} is not a valid type of action") end end |
#get_payload ⇒ Object
220 221 222 223 224 225 226 |
# File 'lib/lifestreamable/lifestreamable.rb', line 220 def get_payload reference_type, reference_id = get_reference owner_type, owner_id = get_owner stream_type = get_stream_type data = get_lifestream_data.to_yaml Struct::LifestreamData.new reference_type, reference_id, owner_type, owner_id, stream_type, data end |
#lifestream_options ⇒ Object
203 204 205 |
# File 'lib/lifestreamable/lifestreamable.rb', line 203 def self.class. end |
#lifestreamable?(action) ⇒ Boolean
207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/lifestreamable/lifestreamable.rb', line 207 def lifestreamable?(action) case self.[:when] when NilClass, TrueClass, :true, TRUE_REGEX true when FalseClass, :false, FALSE_REGEX false when Proc self.[:when].call(self, action) when String, Symbol send(self.[:when].to_s, action) end end |