Module: Marty::PgEnum

Included in:
EnumEventOperation
Defined in:
app/models/marty/pg_enum.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



17
18
19
20
21
22
23
# File 'app/models/marty/pg_enum.rb', line 17

def self.extended(base)
  base.class_eval do
    const_set :GET_ALL_SIG,      [0, 1]
    const_set :LOOKUP_SIG,       [1, 2]
    const_set :FIND_BY_NAME_SIG, [1, 2]
  end
end

Instance Method Details

#[](i0, i1 = nil) ⇒ Object Also known as: find_by_name, lookup



3
4
5
6
7
8
9
10
11
# File 'app/models/marty/pg_enum.rb', line 3

def [](i0, i1=nil)
  # if i1 is provided, then i0 is a pt and we ignore it.
  index = (i1 || i0).to_s

  raise "no such #{self.name}: '#{index}'" unless
    self::VALUES.include?(index)

  index
end

#get_all(pt = nil) ⇒ Object



13
14
15
# File 'app/models/marty/pg_enum.rb', line 13

def get_all(pt=nil)
  self::VALUES.map(&:to_s)
end

#seedObject



25
26
# File 'app/models/marty/pg_enum.rb', line 25

def seed
end