Module: Groupify::Mongoid::GroupMember
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/groupify/adapter/mongoid.rb
Overview
Usage:
class User
include Mongoid::Document
acts_as_group_member
...
end
user.groups << group
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #in_all_groups?(*groups) ⇒ Boolean
- #in_any_group?(*groups) ⇒ Boolean
- #in_group?(group) ⇒ Boolean
- #shares_any_group?(other) ⇒ Boolean
Instance Method Details
#in_all_groups?(*groups) ⇒ Boolean
155 156 157 |
# File 'lib/groupify/adapter/mongoid.rb', line 155 def in_all_groups?(*groups) Set.new(groups.flatten) == Set.new(self.named_groups) end |
#in_any_group?(*groups) ⇒ Boolean
148 149 150 151 152 153 |
# File 'lib/groupify/adapter/mongoid.rb', line 148 def in_any_group?(*groups) groups.flatten.each do |group| return true if in_group?(group) end return false end |
#in_group?(group) ⇒ Boolean
144 145 146 |
# File 'lib/groupify/adapter/mongoid.rb', line 144 def in_group?(group) self.groups.include?(group) end |
#shares_any_group?(other) ⇒ Boolean
159 160 161 |
# File 'lib/groupify/adapter/mongoid.rb', line 159 def shares_any_group?(other) in_any_group?(other.groups) end |