Class: RailsAttrEnum::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails_attr_enum/entry.rb

Overview

Enum entry class

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#const_nameObject

Returns the value of attribute const_name

Returns:

  • (Object)

    the current value of const_name



5
6
7
# File 'lib/rails_attr_enum/entry.rb', line 5

def const_name
  @const_name
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



5
6
7
# File 'lib/rails_attr_enum/entry.rb', line 5

def key
  @key
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



5
6
7
# File 'lib/rails_attr_enum/entry.rb', line 5

def label
  @label
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



5
6
7
# File 'lib/rails_attr_enum/entry.rb', line 5

def value
  @value
end

Instance Method Details

#to_hObject



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