Skip to content

Commit

Permalink
activities/subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
xdite committed Jun 13, 2012
1 parent f34b842 commit 969fb47
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion bustle.gemspec
Expand Up @@ -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'
Expand Down
25 changes: 18 additions & 7 deletions lib/bustle/activities.rb
@@ -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
6 changes: 3 additions & 3 deletions lib/bustle/subscriptions.rb
Expand Up @@ -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
Expand Down

0 comments on commit 969fb47

Please sign in to comment.