Sha256: 35b65e5f7f2461461cbc2ebe2fd744c0757134fc54cdf7b138b61ea36d210aca
Contents?: true
Size: 434 Bytes
Versions: 1
Compression:
Stored size: 434 Bytes
Contents
require 'ostruct' module RailsAttrEnum ## Enum entry class Entry = Struct.new(:const_name, :key, :value, :label) do # Add a to_h method if it doesn't exist (< ruby 2.0) unless nil.respond_to?(:to_h) def to_h # Hash[*(entry.members.flat_map { |key| [key, entry.send(key)] })] Hash[members.map { |key| [key, send(key)] }] end end def to_json(*args) to_h.to_json end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_attr_enum-0.0.6 | lib/rails_attr_enum/entry.rb |