Class: IshManager::Ability

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

Instance Method Summary collapse

Constructor Details

#initialize(user_profile) ⇒ 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/models/ish_manager/ability.rb', line 5

def initialize 

  #
  # signed in user
  #
  if !.blank?

    #
    # only sudoer... total power
    #
    if .sudoer?
      can :manage, :all
    end

    can [ :home ], ::IshManager::Ability

    #
    # role admin
    #
    if  && [ :admin ].include?( .role_name )

      can [ :friends_index, :friends_new ], ::Ish::UserProfile

      can [ :index, :new, :create, :create_photo ], ::Gallery
      can [ :edit, :update ], ::Gallery do |g|
        !g.is_trash && ( g.is_public || g. ==  )
      end
      can [ :edit, :index, :show, :update,
        :new_marker, :edit_marker, :create_marker, :update_marker,
      ], Gameui::Map

      can [ :home, :sites_index ], ::Manager

      can [ :new ], Newsitem

      can [ :index, :new, :create ], Report
      can [ :edit, :update, :destroy ], Report do |g|
        !g.is_trash && ( g.is_public || g. ==  )
      end

      # can [ :manage ], ::Warbler::StockWatch

      # can [ :index, :new, :create ], ::Tag

      can [ :index, :new, :create ], ::Video
      can [ :edit, :update, :destroy ], ::Video do |v|
        !v.is_trash && ( v.is_public || v. ==  )
      end

    end

    #
    # role manager
    #
    if  && :manager == .role_name

       can [ :edit, :index, :show, :update,
             :new_marker, :edit_marker, :create_marker, :update_marker,
       ], Gameui::Map

    end


    #
    # role guy
    #
    if  && :guy == .role_name

      can [ :index, :new, :create ], ::Gallery
      can [ :show, :edit, :update, :create_photo ], ::Gallery do |gallery|
        gallery. == 
      end
      can [ :show ], ::Gallery do |gallery|
        gallery.shared_profiles.include? 
      end

      # can [ :create, :index, :new ], Photo

      # can [ :index ], ::Report

      # can [ :index ], ::Video

    end

  end

  #
  # anonymous user
  #
   ||= ::Ish::UserProfile.new

  can [ :open_permission ], IshManager::Ability

  can [ :show ], ::Gallery do |gallery|
    gallery.is_public
  end

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

  can [ :new, :create ], Ish::EmailUnsubscribe

end