Sha256: 5657458c52b8239e0eb884eba7cc5675a4e574951aff7c3d91620ed5f753ec04

Contents?: true

Size: 568 Bytes

Versions: 26

Compression:

Stored size: 568 Bytes

Contents

module Marty::PgEnum

  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

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

  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

  def seed
  end

  alias_method :find_by_name, :[]
  alias_method :lookup, :[]
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
marty-2.5.2 app/models/marty/pg_enum.rb
marty-2.5.1 app/models/marty/pg_enum.rb
marty-2.5.0 app/models/marty/pg_enum.rb
marty-2.4.9 app/models/marty/pg_enum.rb
marty-2.4.8 app/models/marty/pg_enum.rb
marty-2.4.7 app/models/marty/pg_enum.rb
marty-2.4.6 app/models/marty/pg_enum.rb
marty-2.4.5 app/models/marty/pg_enum.rb
marty-2.4.4 app/models/marty/pg_enum.rb
marty-2.4.3 app/models/marty/pg_enum.rb
marty-2.4.2 app/models/marty/pg_enum.rb
marty-2.4.1 app/models/marty/pg_enum.rb
marty-2.4.0 app/models/marty/pg_enum.rb
marty-2.3.15 app/models/marty/pg_enum.rb
marty-2.3.14 app/models/marty/pg_enum.rb
marty-2.3.13 app/models/marty/pg_enum.rb
marty-2.3.12 app/models/marty/pg_enum.rb
marty-2.3.11 app/models/marty/pg_enum.rb
marty-2.3.10 app/models/marty/pg_enum.rb
marty-2.3.9 app/models/marty/pg_enum.rb