Module: DmCore::Concerns::PublicPrivate::ClassMethods
- Defined in:
- app/models/dm_core/concerns/public_private.rb
Instance Method Summary collapse
-
#available_to_user(user) ⇒ Object
Get list of available objects for user ——————————————————————————.
Instance Method Details
#available_to_user(user) ⇒ Object
Get list of available objects for user
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'app/models/dm_core/concerns/public_private.rb', line 130 def available_to_user(user) if user.nil? #--- not logged in, only public objects = self.by_public.published elsif user.is_admin? objects = self.all else #--- all public/protected, as well as private that they are a member and subscriptions objects = self.all_public.published objects += self.by_private.published.with_role(:member, user) self.by_private.published.where('owner_id IS NOT NULL').each do |item| objects << item if item.owner.member?(user) end objects += self.by_subscription.published if user.is_paid_subscriber? return objects end end |