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)
  options = args.extract_options!
  name = args[0]
  badge = Badge.find_or_create_by_name(name, options)
  badgings.create(:badge_id => badge.id) unless has_badge?(badge)
end

#badgesObject



33
34
35
# File 'lib/badgeable/adapters/mongoid_adapter.rb', line 33

def badges
  Badge.where(:_id.in => badgings.map(&:badge_id))
end

#unseen_badgesObject



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