Module: ActiveMetadata::Stream
- Defined in:
- lib/active_metadata/stream.rb
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary collapse
-
.by_group(group, *args) ⇒ Object
same as #stream_for but not filtered by field.
- .collect_stream_items_by_group(group, options) ⇒ Object
- .included(base) ⇒ Object
- .sort_stream(stream, order_by) ⇒ Object
Class Method Details
.by_group(group, *args) ⇒ Object
same as #stream_for but not filtered by field
9 10 11 12 13 |
# File 'lib/active_metadata/stream.rb', line 9 def by_group group, *args = args. order_by = .delete(:order_by) || :created_at sort_stream(collect_stream_items_by_group(group, ), order_by) end |
.collect_stream_items_by_group(group, options) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/active_metadata/stream.rb', line 19 def collect_stream_items_by_group group, res = [] ActiveMetadata::CONFIG['streamables'].each do |model| res.concat "ActiveMetadata::#{model.to_s.capitalize}".to_class.send(:by_group, group.to_s, ).collect { |el| el } end res end |
.included(base) ⇒ Object
4 5 6 |
# File 'lib/active_metadata/stream.rb', line 4 def self.included(base) base.send :include, InstanceMethods end |
.sort_stream(stream, order_by) ⇒ Object
15 16 17 |
# File 'lib/active_metadata/stream.rb', line 15 def sort_stream stream, order_by stream.sort { |b, a| a.send(order_by) <=> b.send(order_by) } end |