Class: WriterActivityState
- Inherits:
-
Object
- Object
- WriterActivityState
- Includes:
- EnumField::DefineEnum
- Defined in:
- app/models/enums/writer_activity_state.rb
Instance Attribute Summary collapse
-
#allow_filter ⇒ Object
readonly
Returns the value of attribute allow_filter.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#css ⇒ Object
readonly
Returns the value of attribute css.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, slug = nil, css = nil, allow_filter = false) ⇒ WriterActivityState
constructor
A new instance of WriterActivityState.
- #title ⇒ Object
- #to_param ⇒ Object
Constructor Details
#initialize(code, slug = nil, css = nil, allow_filter = false) ⇒ WriterActivityState
Returns a new instance of WriterActivityState.
8 9 10 11 12 13 |
# File 'app/models/enums/writer_activity_state.rb', line 8 def initialize(code, slug = nil, css = nil, allow_filter = false) @code = code.to_sym @css = css || slug.to_s @slug = slug.to_sym if slug @allow_filter = allow_filter end |
Instance Attribute Details
#allow_filter ⇒ Object (readonly)
Returns the value of attribute allow_filter.
6 7 8 |
# File 'app/models/enums/writer_activity_state.rb', line 6 def allow_filter @allow_filter end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'app/models/enums/writer_activity_state.rb', line 6 def code @code end |
#css ⇒ Object (readonly)
Returns the value of attribute css.
6 7 8 |
# File 'app/models/enums/writer_activity_state.rb', line 6 def css @css end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
6 7 8 |
# File 'app/models/enums/writer_activity_state.rb', line 6 def slug @slug end |
Class Method Details
.filter_list ⇒ Object
24 25 26 |
# File 'app/models/enums/writer_activity_state.rb', line 24 def filter_list all.select(&:allow_filter) end |
.find_by_slug(slug) ⇒ Object
28 29 30 31 32 |
# File 'app/models/enums/writer_activity_state.rb', line 28 def find_by_slug(slug) return nil if slug.blank? all.find { |i| i.slug == slug.to_sym } if slug.present? end |
Instance Method Details
#title ⇒ Object
19 20 21 |
# File 'app/models/enums/writer_activity_state.rb', line 19 def title I18n.t(code, scope: [:writer_activity_state]) end |
#to_param ⇒ Object
15 16 17 |
# File 'app/models/enums/writer_activity_state.rb', line 15 def to_param @slug end |