Class: FeedbacksPageType
- Inherits:
-
Object
- Object
- FeedbacksPageType
- Includes:
- EnumField::DefineEnum
- Defined in:
- app/models/enums/feedbacks_page_type.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Class Method Summary collapse
Instance Method Summary collapse
- #disabled? ⇒ Boolean
-
#initialize(code, slug = nil, disabled = false) ⇒ FeedbacksPageType
constructor
A new instance of FeedbacksPageType.
- #title ⇒ Object
Constructor Details
#initialize(code, slug = nil, disabled = false) ⇒ FeedbacksPageType
Returns a new instance of FeedbacksPageType.
7 8 9 10 11 |
# File 'app/models/enums/feedbacks_page_type.rb', line 7 def initialize(code, slug = nil, disabled = false) @code = code.to_sym @slug = (slug || code).to_s @disabled = disabled end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'app/models/enums/feedbacks_page_type.rb', line 5 def code @code end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
5 6 7 |
# File 'app/models/enums/feedbacks_page_type.rb', line 5 def disabled @disabled end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
5 6 7 |
# File 'app/models/enums/feedbacks_page_type.rb', line 5 def slug @slug end |
Class Method Details
.enabled ⇒ Object
40 41 42 |
# File 'app/models/enums/feedbacks_page_type.rb', line 40 def enabled all.reject(&:disabled?) end |
.find_by_slug(slug) ⇒ Object
34 35 36 37 38 |
# File 'app/models/enums/feedbacks_page_type.rb', line 34 def find_by_slug(slug) return first if slug.nil? all.detect { |type| type.slug == slug } end |
Instance Method Details
#disabled? ⇒ Boolean
17 18 19 |
# File 'app/models/enums/feedbacks_page_type.rb', line 17 def disabled? @disabled end |
#title ⇒ Object
13 14 15 |
# File 'app/models/enums/feedbacks_page_type.rb', line 13 def title I18n.t(code, scope: [:account, :feedbacks, :type_title]) end |