Permalink
Browse files

activities/subscriptions

  • Loading branch information...
1 parent f34b842 commit 969fb475383016c9de8fa8de46e291e52371d482 @xdite committed Jun 13, 2012
Showing with 24 additions and 13 deletions.
  1. +2 −2 README.md
  2. +1 −1 bustle.gemspec
  3. +18 −7 lib/bustle/activities.rb
  4. +3 −3 lib/bustle/subscriptions.rb
View
@@ -115,9 +115,9 @@ Complete list of APIs to build:
- [x] `Bustle::Subscriber.destroy`
- [x] `Bustle::Publisher.destroy`
- [x] `Bustle::Subscription.destroy`
-- [ ] `Bustle::Activities.for`
+- [x] `Bustle::Activities.for`
- [ ] `Bustle::Subscriber.activities`
-- [ ] `Bustle::Activities.by`
+- [x] `Bustle::Activities.by`
- [ ] `Bustle::Publisher.activities`
- [ ] `Bustle::Activities.filter`
- [ ] `Bustle::Activities.delegate`
View
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
gem.version = Bustle::VERSION
gem.add_dependency 'activesupport', '>= 3.0'
- gem.add_dependency 'orm_adapter', '~> 0.1.0'
+ gem.add_dependency 'orm_adapter' #, '~> 0.1.0'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'simplecov'
View
@@ -1,12 +1,23 @@
module Bustle
class Activities
- def self.add(publisher, action, activity_resource)
- Activity.to_adapter.create!(
- :resource_class => activity_resource.class.name,
- :resource_id => activity_resource.id,
- :action => action,
- :publisher_id => publisher.id
- )
+ class << self
+ def add(publisher, action, activity_resource)
+ Activity.to_adapter.create!(
+ :resource_class => activity_resource.class.name,
+ :resource_id => activity_resource.id,
+ :action => action,
+ :publisher_id => publisher.id
+ )
+ end
+
+ def for(subscriber)
+ publisher_ids = Subscriptions.for(subscriber).map(&:publisher_id)
+ Activity.where(:publisher_id => publisher_ids )
+ end
+
+ def by(publisher)
+ Activity.to_adapter.where(:publisher_id => publisher.id )
+ end
end
end
end
@@ -20,19 +20,19 @@ def remove(publisher, subscriber)
end
def by(publisher)
- Subscription.to_adapter.find_all(
+ Subscription.where(
:publisher_id => publisher.id
)
end
def for(subscriber)
- Subscription.to_adapter.find_all(
+ Subscription.where(
:subscriber_id => subscriber.id
)
end
def filter(options = {})
- Subscription.to_adapter.find_all(options)
+ Subscription.where(options)
end
end
end

0 comments on commit 969fb47

Please sign in to comment.