Class: VoteType

Inherits:
Object
  • Object
show all
Includes:
EnumField::DefineEnum
Defined in:
app/models/enums/vote_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ VoteType

Returns a new instance of VoteType.



8
9
10
# File 'app/models/enums/vote_type.rb', line 8

def initialize(code)
  @code = code.to_sym
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'app/models/enums/vote_type.rb', line 6

def code
  @code
end

Class Method Details

.parse(value) ⇒ Object



16
17
18
19
20
# File 'app/models/enums/vote_type.rb', line 16

def self.parse(value)
  return if value.blank?

  all.detect { |item| item.code.to_s == value.to_s.downcase }
end

Instance Method Details

#titleObject



12
13
14
# File 'app/models/enums/vote_type.rb', line 12

def title
  I18n.t(code, scope: [:vote_type])
end