Class: WriterSortType
- Inherits:
-
Object
- Object
- WriterSortType
- Includes:
- EnumField::DefineEnum
- Defined in:
- app/models/enums/writer_sort_type.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, slug = nil) ⇒ WriterSortType
constructor
A new instance of WriterSortType.
- #title ⇒ Object
- #to_param ⇒ Object
Constructor Details
#initialize(code, slug = nil) ⇒ WriterSortType
Returns a new instance of WriterSortType.
8 9 10 11 |
# File 'app/models/enums/writer_sort_type.rb', line 8 def initialize(code, slug = nil) @code = code.to_sym @slug = slug || @code.to_s end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'app/models/enums/writer_sort_type.rb', line 6 def code @code end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
6 7 8 |
# File 'app/models/enums/writer_sort_type.rb', line 6 def slug @slug end |
Class Method Details
.default ⇒ Object
27 28 29 |
# File 'app/models/enums/writer_sort_type.rb', line 27 def default overall_ranking end |
.find_by_slug(slug) ⇒ Object
31 32 33 34 35 |
# File 'app/models/enums/writer_sort_type.rb', line 31 def find_by_slug(slug) return nil if slug.blank? all.detect { |i| i.slug.casecmp(slug) == 0 } end |
Instance Method Details
#title ⇒ Object
13 14 15 |
# File 'app/models/enums/writer_sort_type.rb', line 13 def title I18n.t(code, scope: [:sort_order, :title]) end |
#to_param ⇒ Object
22 23 24 |
# File 'app/models/enums/writer_sort_type.rb', line 22 def to_param @code end |