Sha256: 65491940e661b7184a9acd13c9de846e401a539faf64c99258131b1424b0f861

Contents?: true

Size: 721 Bytes

Versions: 6

Compression:

Stored size: 721 Bytes

Contents

module Groonga
  class Record
    attr_reader :table
    attr_reader :id

    def inspect
      super.gsub(/>\z/) do
        "@id=#{@id.inspect}, @table=#{@table.inspect}>"
      end
    end

    def [](name)
      column = find_column(name)
      if column.nil?
        raise InvalidArgument, "unknown column: <#{absolute_column_name(name)}>"
      end
      column[@id]
    end

    def method_missing(name, *args, &block)
      return super unless args.empty?

      column = find_column(name)
      return super if column.nil?

      column[@id]
    end

    private
    def absolute_column_name(name)
      "#{@table.name}.#{name}"
    end

    def find_column(name)
      @table.find_column(name)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rroonga-9.0.7-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-9.0.7-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-9.0.3-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-9.0.3-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-9.0.2-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-9.0.2-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb