Module: Enumerations::Value
- Included in:
- Base
- Defined in:
- lib/enumerations/value.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
Comparison by id, symbol or object.
- #to_i ⇒ Object
- #to_param ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
Instance Method Details
#==(other) ⇒ Object
Comparison by id, symbol or object
Example:
Role.admin == 1 => true
Role.admin == :admin => true
Role.admin == Role.admin => true
Role.admin == 2 => false
Role.admin == :staff => false
Role.admin == Role.staff => false
TODO: test if case..when is working with this
31 32 33 34 35 36 37 |
# File 'lib/enumerations/value.rb', line 31 def ==(other) case other when Fixnum then other == id 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 id end |
#to_param ⇒ Object
15 16 17 |
# File 'lib/enumerations/value.rb', line 15 def to_param id end |
#to_s ⇒ Object
7 8 9 |
# File 'lib/enumerations/value.rb', line 7 def to_s name end |
#to_sym ⇒ Object
11 12 13 |
# File 'lib/enumerations/value.rb', line 11 def to_sym symbol end |