Class: AppealType
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AppealType
- Includes:
- RequiredUniqueName, Toggleable
- Defined in:
- app/models/appeal_type.rb
Constant Summary collapse
- NAME_LIMIT =
50
- PRIORITY_RANGE =
(1..100)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.list_for_visitors ⇒ Object
22 23 24 |
# File 'app/models/appeal_type.rb', line 22 def self.list_for_visitors visible.ordered_by_priority end |
.page_for_administration ⇒ Object
18 19 20 |
# File 'app/models/appeal_type.rb', line 18 def self.page_for_administration ordered_by_priority end |
Instance Method Details
#change_priority(delta) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/appeal_type.rb', line 27 def change_priority(delta) new_priority = priority + delta adjacent = self.class.find_by(priority: new_priority) if adjacent.is_a?(self.class) && (adjacent.id != id) adjacent.update!(priority: priority) end self.update(priority: new_priority) self.class.ordered_by_priority.map { |e| [e.id, e.priority] }.to_h end |