Class: NippoCore::ReportPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- NippoCore::ReportPolicy
- Defined in:
- app/policies/nippo_core/report_policy.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes inherited from ApplicationPolicy
Instance Method Summary collapse
- #create? ⇒ Boolean
- #edit? ⇒ Boolean
-
#index? ⇒ Boolean
TODO: remove.
-
#initialize(user, report) ⇒ ReportPolicy
constructor
A new instance of ReportPolicy.
- #new? ⇒ Boolean
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Methods inherited from ApplicationPolicy
Constructor Details
#initialize(user, report) ⇒ ReportPolicy
Returns a new instance of ReportPolicy.
5 6 7 8 9 |
# File 'app/policies/nippo_core/report_policy.rb', line 5 def initialize(user, report) @user = user @report = report @group = @report.group end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
3 4 5 |
# File 'app/policies/nippo_core/report_policy.rb', line 3 def group @group end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
3 4 5 |
# File 'app/policies/nippo_core/report_policy.rb', line 3 def report @report end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/policies/nippo_core/report_policy.rb', line 3 def user @user end |
Instance Method Details
#create? ⇒ Boolean
24 25 26 |
# File 'app/policies/nippo_core/report_policy.rb', line 24 def create? @group.member?(user) end |
#edit? ⇒ Boolean
28 29 30 |
# File 'app/policies/nippo_core/report_policy.rb', line 28 def edit? @report.user_id == @user.id end |
#index? ⇒ Boolean
TODO: remove
12 13 14 |
# File 'app/policies/nippo_core/report_policy.rb', line 12 def index? @group.member?(user) end |
#new? ⇒ Boolean
20 21 22 |
# File 'app/policies/nippo_core/report_policy.rb', line 20 def new? @group.member?(user) end |
#show? ⇒ Boolean
16 17 18 |
# File 'app/policies/nippo_core/report_policy.rb', line 16 def show? @group.member?(user) end |
#update? ⇒ Boolean
32 33 34 |
# File 'app/policies/nippo_core/report_policy.rb', line 32 def update? @report.user_id == @user.id end |