class DataMapper::Shim::Enum
Attributes
values[RW]
Public Class Methods
[](*values)
click to toggle source
# File lib/data_mapper/shim.rb, line 28 def self.[](*values) self.new(values) end
new(values)
click to toggle source
# File lib/data_mapper/shim.rb, line 32 def initialize(values) # [:active, :inactive] => { :active => 1, :inactive => 2, 1 => :active, 2 => :inactive } self.values = values.each_with_index.inject({}) do |hash, (val, i)| hash[val] = i + 1 hash[i + 1] = val hash end end
Public Instance Methods
[](index)
click to toggle source
# File lib/data_mapper/shim.rb, line 41 def [](index) self.values[index] end