Module: Enumerations::Value
- Included in:
- Base
- Defined in:
- lib/enumerations/value.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
Comparison by symbol or object.
- #to_i ⇒ Object
- #to_param ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
Instance Method Details
#==(other) ⇒ Object
Comparison by symbol or object
Example:
Role.admin == :admin => true
Role.admin == Role.admin => true
Role.admin == :staff => false
Role.admin == Role.staff => false
TODO: test if case..when is working with this
29 30 31 32 33 34 35 |
# File 'lib/enumerations/value.rb', line 29 def ==(other) case other when String then other == to_s when Symbol then other == symbol else super end end |
#to_i ⇒ Object
3 4 5 |
# File 'lib/enumerations/value.rb', line 3 def to_i _values.keys.index(symbol) + 1 end |
#to_param ⇒ Object
11 12 13 |
# File 'lib/enumerations/value.rb', line 11 def to_param to_s end |
#to_s ⇒ Object
7 8 9 |
# File 'lib/enumerations/value.rb', line 7 def to_s symbol.to_s end |
#to_sym ⇒ Object
15 16 17 |
# File 'lib/enumerations/value.rb', line 15 def to_sym symbol end |