Class: NextSges::CollectionType
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- NextSges::CollectionType
- Defined in:
- app/models/next_sges/collection_type.rb
Constant Summary
Constants inherited from ApplicationRecord
ApplicationRecord::CELL_REGEX, ApplicationRecord::DEFAULT_IDENTIFICATION_ENUM, ApplicationRecord::DEFAULT_STATUS_ENUM, ApplicationRecord::MAIL_REGEX
Class Method Summary collapse
Instance Method Summary collapse
- #increment_code ⇒ Object
- #map_for_filter(method_name = :name) ⇒ Object
-
#map_for_select(method_name = :name) ⇒ Object
BEGIN instance methods.
Methods inherited from ApplicationRecord
#create_number, #create_number!, map_for_filter, map_for_select
Class Method Details
.latest_codes ⇒ Object
END
12 13 14 15 |
# File 'app/models/next_sges/collection_type.rb', line 12 def self.latest_codes latest_ids = NextSges::CollectionType.all.group_by{|type| type.code}.map{|code, types| types.sort_by{|type| type.created_at}.last.id}.flatten.compact.uniq where(id: latest_ids) end |
Instance Method Details
#increment_code ⇒ Object
43 44 45 46 47 |
# File 'app/models/next_sges/collection_type.rb', line 43 def increment_code if code == 0 || code.nil? self.code = (NextSges::CollectionType.all.sort_by(&:code).last&.code || 0) + 1 end end |
#map_for_filter(method_name = :name) ⇒ Object
22 23 24 |
# File 'app/models/next_sges/collection_type.rb', line 22 def map_for_filter(method_name = :name) map_for_select(:name) end |
#map_for_select(method_name = :name) ⇒ Object
BEGIN instance methods
18 19 20 |
# File 'app/models/next_sges/collection_type.rb', line 18 def map_for_select(method_name = :name) super(:name) end |