Module: FatFreeCRM::Permissions::ClassMethods

Defined in:
lib/fat_free_crm/permissions.rb

Instance Method Summary collapse

Instance Method Details

#uses_user_permissionsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fat_free_crm/permissions.rb', line 27

def uses_user_permissions
  unless included_modules.include?(InstanceMethods)
    #
    # NOTE: we're deliberately omitting :dependent => :destroy to preserve
    # permissions of deleted objects. This serves two purposes: 1) to be able
    # to implement Recycle Bin/Restore and 2) to honor permissions when
    # displaying "object deleted..." in the activity log.
    #
    has_many :permissions, :as => :asset

    scope :my, lambda {
      current_ability = Ability.new(User.current_user)
      accessible_by(current_ability).readonly(false)
    }

    include FatFreeCRM::Permissions::InstanceMethods
    extend  FatFreeCRM::Permissions::SingletonMethods
  end
end