Sha256: 68f8dec7886eeadb8455cf9d5edc61a3e210c76d95a49b1c887f54e7ba0f2e0c

Contents?: true

Size: 651 Bytes

Versions: 31

Compression:

Stored size: 651 Bytes

Contents

module Marty::PgEnum

  def [](index)
    index = index.to_s

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

    StringEnum.new(index)
  end

  def get_all
    self::VALUES.map { |v| StringEnum.new(v) }
  end

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

  def seed
  end

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

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
marty-1.1.6 app/models/marty/pg_enum.rb
marty-1.1.5 app/models/marty/pg_enum.rb
marty-1.1.4 app/models/marty/pg_enum.rb
marty-1.1.3 app/models/marty/pg_enum.rb
marty-1.1.2 app/models/marty/pg_enum.rb
marty-1.1.1 app/models/marty/pg_enum.rb
marty-1.0.54 app/models/marty/pg_enum.rb
marty-1.0.53 app/models/marty/pg_enum.rb
marty-1.0.52 app/models/marty/pg_enum.rb
marty-1.0.51 app/models/marty/pg_enum.rb
marty-1.0.50 app/models/marty/pg_enum.rb
marty-1.0.48 app/models/marty/pg_enum.rb
marty-1.0.47 app/models/marty/pg_enum.rb
marty-1.0.46 app/models/marty/pg_enum.rb
marty-1.0.44 app/models/marty/pg_enum.rb
marty-1.0.43 app/models/marty/pg_enum.rb
marty-1.0.42 app/models/marty/pg_enum.rb
marty-1.0.41 app/models/marty/pg_enum.rb
marty-1.0.39 app/models/marty/pg_enum.rb
marty-1.0.38 app/models/marty/pg_enum.rb