Class: Storytime::MediaPolicy
- Inherits:
-
Object
- Object
- Storytime::MediaPolicy
- Defined in:
- app/policies/storytime/media_policy.rb
Instance Attribute Summary collapse
-
#media ⇒ Object
readonly
Returns the value of attribute media.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, media) ⇒ MediaPolicy
constructor
A new instance of MediaPolicy.
Constructor Details
#initialize(user, media) ⇒ MediaPolicy
Returns a new instance of MediaPolicy.
5 6 7 8 |
# File 'app/policies/storytime/media_policy.rb', line 5 def initialize(user, media) @user = user @media = media end |
Instance Attribute Details
#media ⇒ Object (readonly)
Returns the value of attribute media.
3 4 5 |
# File 'app/policies/storytime/media_policy.rb', line 3 def media @media end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/policies/storytime/media_policy.rb', line 3 def user @user end |
Instance Method Details
#create? ⇒ Boolean
14 15 16 |
# File 'app/policies/storytime/media_policy.rb', line 14 def create? @media.user == @user end |
#destroy? ⇒ Boolean
18 19 20 |
# File 'app/policies/storytime/media_policy.rb', line 18 def destroy? true end |
#index? ⇒ Boolean
10 11 12 |
# File 'app/policies/storytime/media_policy.rb', line 10 def index? !@user.nil? end |