Module: Badgeable::Adapters::InstanceMethods
- Defined in:
- lib/badgeable/adapters/mongoid_adapter.rb
Instance Method Summary collapse
Instance Method Details
#award_badge(*args) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/badgeable/adapters/mongoid_adapter.rb', line 26 def award_badge(*args) = args. name = args[0] badge = Badge.find_or_create_by_name(name, ) badgings.create(:badge_id => badge.id) unless has_badge?(badge) end |
#badges ⇒ Object
33 34 35 |
# File 'lib/badgeable/adapters/mongoid_adapter.rb', line 33 def badges Badge.where(:_id.in => badgings.map(&:badge_id)) end |
#unseen_badges ⇒ Object
37 38 39 |
# File 'lib/badgeable/adapters/mongoid_adapter.rb', line 37 def unseen_badges Badge.where(:_id.in => badgings.unseen.map(&:badge_id)) end |