Class: Lifestreamable::Lifestream
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Lifestreamable::Lifestream
- Defined in:
- lib/lifestreamable/lifestream.rb
Constant Summary collapse
- DEFAULT_LIMIT_PER_PAGE =
25
- DEFAULT_PAGE =
0
Class Method Summary collapse
-
.find_by_reference_type_and_reference_id_and_stream_type(reference_type, reference_id, stream_type) ⇒ Object
FINDERS.
- .find_lifestream_for_group(owner, group, *options) ⇒ Object
- .find_lifestream_for_owner(owner, *options) ⇒ Object
-
.process(action, struct) ⇒ Object
CREATION DU LIFESTREAM.
Instance Method Summary collapse
- #object_data ⇒ Object (also: #object_hash)
Class Method Details
.find_by_reference_type_and_reference_id_and_stream_type(reference_type, reference_id, stream_type) ⇒ Object
FINDERS
39 40 41 |
# File 'lib/lifestreamable/lifestream.rb', line 39 def find_by_reference_type_and_reference_id_and_stream_type(reference_type, reference_id, stream_type) find(:last, :conditions=>['reference_type = ? and reference_id = ? and stream_type = ?', reference_type, reference_id, stream_type]) end |
.find_lifestream_for_group(owner, group, *options) ⇒ Object
48 49 50 51 |
# File 'lib/lifestreamable/lifestream.rb', line 48 def find_lifestream_for_group(owner, group, *) opts = owner, group, [0] results = find :all, opts end |
.find_lifestream_for_owner(owner, *options) ⇒ Object
43 44 45 46 |
# File 'lib/lifestreamable/lifestream.rb', line 43 def find_lifestream_for_owner(owner, *) opts = owner, [0] results = find :all, opts end |
.process(action, struct) ⇒ Object
CREATION DU LIFESTREAM
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lifestreamable/lifestream.rb', line 19 def process(action, struct) # put explicitly the actions accepted puts "calling process #{action} #{struct.inspect}" case action when :create create get_payload(struct) when :update l = Lifestream.find_by_reference_type_and_reference_id_and_stream_type(struct.reference_type, struct.reference_id, struct.stream_type) l.update_attributes get_payload(struct) unless l.blank? when :destroy l = Lifestream.find_by_reference_type_and_reference_id_and_stream_type(struct.reference_type, struct.reference_id, struct.stream_type) l.destroy unless l.blank? else raise LifestreamableException.new "unknown action #{action} in Lifestreamable::Lifestream.process" end end |
Instance Method Details
#object_data ⇒ Object Also known as: object_hash
10 11 12 |
# File 'lib/lifestreamable/lifestream.rb', line 10 def object_data YAML.load(self.object_data_hash) end |