Class: HuntersImprovement
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- HuntersImprovement
- Defined in:
- app/models/hunters_improvement.rb
Overview
Improvements taken by the Hunter One is unlocked every 5 Experience
Schema Information
Table name: hunters_improvements
Instance Attribute Summary collapse
Class Method Summary collapse
-
.policy_class ⇒ Object
This is the Pundit Policy that governs HunterImprovement access.
Instance Method Summary collapse
Instance Attribute Details
#hunter_id ⇒ Integer
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 |
# File 'app/models/hunters_improvement.rb', line 18 class HuntersImprovement < ApplicationRecord belongs_to :hunter belongs_to :improvement after_create :apply_improvement validate :validate_hunter, on: :create validates :improvement_id, uniqueness: { scope: :hunter_id } def apply_improvement unless ImproveHunter.for(improvement).new(self).improve raise ActiveRecord::RecordInvalid end hunter.gain_experience(-5) end def validate_hunter ImproveHunter.for(improvement).new(self).valid? end # This is the Pundit Policy that governs HunterImprovement access # # @see HuntersImprovementPolicy def self.policy_class HuntersImprovementPolicy end end |
#id ⇒ Object
Returns [].
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 |
# File 'app/models/hunters_improvement.rb', line 18 class HuntersImprovement < ApplicationRecord belongs_to :hunter belongs_to :improvement after_create :apply_improvement validate :validate_hunter, on: :create validates :improvement_id, uniqueness: { scope: :hunter_id } def apply_improvement unless ImproveHunter.for(improvement).new(self).improve raise ActiveRecord::RecordInvalid end hunter.gain_experience(-5) end def validate_hunter ImproveHunter.for(improvement).new(self).valid? end # This is the Pundit Policy that governs HunterImprovement access # # @see HuntersImprovementPolicy def self.policy_class HuntersImprovementPolicy end end |
#improvable ⇒ Hash
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 |
# File 'app/models/hunters_improvement.rb', line 18 class HuntersImprovement < ApplicationRecord belongs_to :hunter belongs_to :improvement after_create :apply_improvement validate :validate_hunter, on: :create validates :improvement_id, uniqueness: { scope: :hunter_id } def apply_improvement unless ImproveHunter.for(improvement).new(self).improve raise ActiveRecord::RecordInvalid end hunter.gain_experience(-5) end def validate_hunter ImproveHunter.for(improvement).new(self).valid? end # This is the Pundit Policy that governs HunterImprovement access # # @see HuntersImprovementPolicy def self.policy_class HuntersImprovementPolicy end end |
#improvement_id ⇒ Integer
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 |
# File 'app/models/hunters_improvement.rb', line 18 class HuntersImprovement < ApplicationRecord belongs_to :hunter belongs_to :improvement after_create :apply_improvement validate :validate_hunter, on: :create validates :improvement_id, uniqueness: { scope: :hunter_id } def apply_improvement unless ImproveHunter.for(improvement).new(self).improve raise ActiveRecord::RecordInvalid end hunter.gain_experience(-5) end def validate_hunter ImproveHunter.for(improvement).new(self).valid? end # This is the Pundit Policy that governs HunterImprovement access # # @see HuntersImprovementPolicy def self.policy_class HuntersImprovementPolicy end end |
Class Method Details
.policy_class ⇒ Object
This is the Pundit Policy that governs HunterImprovement access
40 41 42 |
# File 'app/models/hunters_improvement.rb', line 40 def self.policy_class HuntersImprovementPolicy end |
Instance Method Details
#apply_improvement ⇒ Object
26 27 28 29 30 31 |
# File 'app/models/hunters_improvement.rb', line 26 def apply_improvement unless ImproveHunter.for(improvement).new(self).improve raise ActiveRecord::RecordInvalid end hunter.gain_experience(-5) end |
#validate_hunter ⇒ Object
33 34 35 |
# File 'app/models/hunters_improvement.rb', line 33 def validate_hunter ImproveHunter.for(improvement).new(self).valid? end |