Module: ChalkDust
- Defined in:
- lib/chalk_dust.rb,
lib/chalk_dust/version.rb,
lib/chalk_dust/rails/generators/install_migrations.rb
Defined Under Namespace
Modules: Generators
Classes: ActivityItem, Connection
Constant Summary
collapse
- VERSION =
"0.0.2"
Class Method Summary
collapse
Class Method Details
.activity_feed_for(subscriber, options = {}) ⇒ Object
59
60
61
62
63
|
# File 'lib/chalk_dust.rb', line 59
def self.activity_feed_for(subscriber, options = {})
activity_items = ActivityItem.for_owner(subscriber)
activity_items = activity_items.since(options[:since]) if options[:since].present?
activity_items
end
|
.publish_event(performer, event, target, options = {}) ⇒ Object
publishes an event where X (performer) did Y (event) to Z (target) to every subscriber of the target
49
50
51
52
53
54
55
56
57
|
# File 'lib/chalk_dust.rb', line 49
def self.publish_event(performer, event, target, options = {})
root_publisher = options.fetch(:root, target)
subscribers_of(root_publisher).map do |subscriber|
ActivityItem.create(:performer => performer,
:event => event,
:target => target,
:owner => subscriber)
end
end
|
.self_subscribe(publisher_subscriber) ⇒ Object
43
44
45
|
# File 'lib/chalk_dust.rb', line 43
def self.self_subscribe(publisher_subscriber)
subscribe(publisher_subscriber, :to => publisher_subscriber)
end
|
.subscribe(subscriber, options) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/chalk_dust.rb', line 32
def self.subscribe(subscriber, options)
publisher = options.fetch(:to)
undirected = options.fetch(:undirected, false)
Connection.create(:subscriber => subscriber, :publisher => publisher)
Connection.create(:subscriber => publisher, :publisher => subscriber) if undirected
end
|
.subscribers_of(publisher) ⇒ Object
39
40
41
|
# File 'lib/chalk_dust.rb', line 39
def self.subscribers_of(publisher)
Connection.subscribers_of(publisher)
end
|