Class: Ishapi::Ability

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
app/models/ishapi/ability.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Ability

Returns a new instance of Ability.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/ishapi/ability.rb', line 5

def initialize user

  #
  # signed in user
  #
  unless user.blank?

    if user.profile && user.profile.manager?
      can :manage, :all
    end

    can [ :show ], Gallery do |gallery|
      gallery.user == user
    end
    
  end
  user ||= User.new
  
  can [ :read ], Gallery do |gallery|
    gallery.is_public
  end

  can [ :read ], Report do |report|
    report.is_public
  end
  
end