Class: Storytime::SubscriptionPolicy
- Inherits:
-
Object
- Object
- Storytime::SubscriptionPolicy
- Defined in:
- app/policies/storytime/subscription_policy.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, record) ⇒ SubscriptionPolicy
constructor
A new instance of SubscriptionPolicy.
- #manage? ⇒ Boolean
- #new? ⇒ Boolean
- #permitted_attributes ⇒ Object
- #update? ⇒ Boolean
Constructor Details
#initialize(user, record) ⇒ SubscriptionPolicy
Returns a new instance of SubscriptionPolicy.
5 6 7 8 |
# File 'app/policies/storytime/subscription_policy.rb', line 5 def initialize(user, record) @user = user @post = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
3 4 5 |
# File 'app/policies/storytime/subscription_policy.rb', line 3 def record @record end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/policies/storytime/subscription_policy.rb', line 3 def user @user end |
Instance Method Details
#create? ⇒ Boolean
18 19 20 |
# File 'app/policies/storytime/subscription_policy.rb', line 18 def create? manage? end |
#destroy? ⇒ Boolean
30 31 32 |
# File 'app/policies/storytime/subscription_policy.rb', line 30 def destroy? manage? end |
#edit? ⇒ Boolean
22 23 24 |
# File 'app/policies/storytime/subscription_policy.rb', line 22 def edit? manage? end |
#index? ⇒ Boolean
10 11 12 |
# File 'app/policies/storytime/subscription_policy.rb', line 10 def index? manage? end |
#manage? ⇒ Boolean
34 35 36 37 38 |
# File 'app/policies/storytime/subscription_policy.rb', line 34 def manage? action = Storytime::Action.find_by(guid: "d29d76") role = @user.storytime_role_in_site(Storytime::Site.current) role.present? && role.allowed_actions.include?(action) end |
#new? ⇒ Boolean
14 15 16 |
# File 'app/policies/storytime/subscription_policy.rb', line 14 def new? manage? end |
#permitted_attributes ⇒ Object
40 41 42 |
# File 'app/policies/storytime/subscription_policy.rb', line 40 def permitted_attributes [:email, :subscribed] end |
#update? ⇒ Boolean
26 27 28 |
# File 'app/policies/storytime/subscription_policy.rb', line 26 def update? manage? end |