Sha256: 63c97e16daaaa1d2707a47049dbffae43ec6144b7eaf86a965baddf28650d75a

Contents?: true

Size: 741 Bytes

Versions: 24

Compression:

Stored size: 741 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)
      Context.instance[absolute_column_name(name)]
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rroonga-7.1.1-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-7.1.1-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-7.0.2-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-7.0.2-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.1.3-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.1.3-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.1.0-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.1.0-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.9-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.9-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.7-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.7-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.5-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.5-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.4-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.4-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.2-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.2-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.0-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb
rroonga-6.0.0-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/record.rb