Class: Ishapi::Ability
- Inherits:
-
Object
- Object
- Ishapi::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/ishapi/ability.rb
Instance Method Summary collapse
-
#initialize(user_profile) ⇒ Ability
constructor
A new instance of Ability.
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/models/ishapi/ability.rb', line 5 def initialize user_profile ## ## super user ## if %w| [email protected] |.include?( user_profile&.email ) can [ :manage ], :all end # # signed in user_profile # if user_profile.present? can [ :my_index ], Gallery can [ :show ], Gallery do |gallery| ( gallery.user_profile == user_profile ) || # my own (!gallery.is_trash && gallery.is_public ) || # public (!gallery.is_trash && gallery.shared_profiles.include?( user_profile ) ) # shared with me end can [ :do_purchase ], ::Gameui can [ :show ], ::Gameui::Map do |map| map.creator_profile == user_profile end can [ :destroy ], Newsitem do |n| n.map.creator_profile.id.to_s == user_profile.id.to_s end can [ :create, :unlock ], ::Ish::Payment can [ :buy_stars ], ::Ish::UserProfile ## ## superuser ## if %w| [email protected] [email protected] [email protected] |.include?( user_profile.email ) can [ :manage ], ::Ishapi can [ :manage ], ::Ish::EmailContext can [ :show ], ::Office::EmailMessage end end # # anonymous user # user ||= User.new can [ :show ], Ish::UserProfile can [ :update ], Ish::UserProfile do |p| p.user.id.to_s == user.id.to_s end ## ## E ## can [ :create ], Ish::EmailUnsubscribe # # G # # can [ :index ], Gallery can [ :show ], Gallery do |gallery| gallery.is_public && !gallery.is_trash end # # I # can [ :fb_sign_in, :long_term_token, :open_permission, :welcome_home ], Ishapi # # M # can [ :index ], ::Gameui::Map can [ :show ], ::Gameui::Map do |map| map.is_public || map.shared_profiles.include?( user_profile ) end can [ :show ], ::Gameui::Marker do |m| m.is_public end # # O # can [ :show ], ::Office::ObfuscatedRedirect can [ :view_chain ], ::Iro::OptionPriceItem # # P # can [ :show ], Photo # # R # can [ :index ], Report can [ :my_index, :show ], Report do |report| report.is_public end # # S # # # T # # # V # # can [ :index, :my_index ], Video can [ :show ], Video do |video| video.is_public end end |