Class: Storytime::SitePolicy
- Inherits:
-
Object
- Object
- Storytime::SitePolicy
- Defined in:
- app/policies/storytime/site_policy.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
-
#initialize(user, site) ⇒ SitePolicy
constructor
A new instance of SitePolicy.
- #manage? ⇒ Boolean
- #new? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, site) ⇒ SitePolicy
Returns a new instance of SitePolicy.
5 6 7 8 |
# File 'app/policies/storytime/site_policy.rb', line 5 def initialize(user, site) @user = user @site = site end |
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
3 4 5 |
# File 'app/policies/storytime/site_policy.rb', line 3 def site @site end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/policies/storytime/site_policy.rb', line 3 def user @user end |
Instance Method Details
#create? ⇒ Boolean
16 17 18 |
# File 'app/policies/storytime/site_policy.rb', line 16 def create? true # !Site.any? end |
#destroy? ⇒ Boolean
32 33 34 |
# File 'app/policies/storytime/site_policy.rb', line 32 def destroy? manage? end |
#edit? ⇒ Boolean
28 29 30 |
# File 'app/policies/storytime/site_policy.rb', line 28 def edit? update? end |
#manage? ⇒ Boolean
10 11 12 13 14 |
# File 'app/policies/storytime/site_policy.rb', line 10 def manage? action = Storytime::Action.find_by(guid: "47342a") role = @user.storytime_role_in_site(Storytime::Site.current) role.present? && role.allowed_actions.include?(action) end |
#new? ⇒ Boolean
20 21 22 |
# File 'app/policies/storytime/site_policy.rb', line 20 def new? create? end |
#update? ⇒ Boolean
24 25 26 |
# File 'app/policies/storytime/site_policy.rb', line 24 def update? manage? end |