Class: RailsAttrEnum::Entry
- Inherits:
-
Struct
- Object
- Struct
- RailsAttrEnum::Entry
- Defined in:
- lib/rails_attr_enum/entry.rb
Overview
Enum entry class
Instance Attribute Summary collapse
-
#const_name ⇒ Object
Returns the value of attribute const_name.
-
#key ⇒ Object
Returns the value of attribute key.
-
#label ⇒ Object
Returns the value of attribute label.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#const_name ⇒ Object
Returns the value of attribute const_name
5 6 7 |
# File 'lib/rails_attr_enum/entry.rb', line 5 def const_name @const_name end |
#key ⇒ Object
Returns the value of attribute key
5 6 7 |
# File 'lib/rails_attr_enum/entry.rb', line 5 def key @key end |
#label ⇒ Object
Returns the value of attribute label
5 6 7 |
# File 'lib/rails_attr_enum/entry.rb', line 5 def label @label end |
#value ⇒ Object
Returns the value of attribute value
5 6 7 |
# File 'lib/rails_attr_enum/entry.rb', line 5 def value @value end |
Instance Method Details
#to_h ⇒ Object
8 9 10 |
# File 'lib/rails_attr_enum/entry.rb', line 8 def to_h Hash[members.map { |key| [key, send(key)] }] end |
#to_json(*args) ⇒ Object
13 14 15 |
# File 'lib/rails_attr_enum/entry.rb', line 13 def to_json(*args) to_h.to_json end |