Sha256: 1a868f9358625fc194e5b919b48de6b1a8f55c1aeddc314637a397bd30acd803

Contents?: true

Size: 602 Bytes

Versions: 30

Compression:

Stored size: 602 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)

    StringEnum.new(index)
  end

  def get_all(pt=nil)
    self::VALUES.map { |v| StringEnum.new(v) }
  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

30 entries across 30 versions & 1 rubygems

Version Path
marty-2.1.5 app/models/marty/pg_enum.rb
marty-2.3.0 app/models/marty/pg_enum.rb
marty-2.1.4 app/models/marty/pg_enum.rb
marty-2.1.3 app/models/marty/pg_enum.rb
marty-2.1.2 app/models/marty/pg_enum.rb
marty-2.1.1 app/models/marty/pg_enum.rb
marty-2.1.0 app/models/marty/pg_enum.rb
marty-2.0.9 app/models/marty/pg_enum.rb
marty-2.0.8 app/models/marty/pg_enum.rb
marty-2.0.7 app/models/marty/pg_enum.rb
marty-2.0.6 app/models/marty/pg_enum.rb
marty-2.0.5 app/models/marty/pg_enum.rb
marty-2.0.4 app/models/marty/pg_enum.rb
marty-2.0.3 app/models/marty/pg_enum.rb
marty-2.0.2 app/models/marty/pg_enum.rb
marty-2.0.1 app/models/marty/pg_enum.rb
marty-2.0.0 app/models/marty/pg_enum.rb
marty-1.2.9 app/models/marty/pg_enum.rb
marty-1.2.8 app/models/marty/pg_enum.rb
marty-1.2.7 app/models/marty/pg_enum.rb