Sha256: f2b043a2eb972d04af0c48284edaf309144a5e24d4d57c0d97c259adef684ad5

Contents?: true

Size: 1.68 KB

Versions: 34

Compression:

Stored size: 1.68 KB

Contents

# -*- coding: utf-8 -*-
#
# Copyright (C) 2010  Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

module Groonga
  class ViewRecord
    # レコードが所属するビュー
    attr_reader :view
    # レコードのID
    attr_reader :id

    # _table_の_id_に対応するレコードを作成する。
    def initialize(view, id)
      @view = view
      @id = id
    end

    # call-seq:
    #   record == other -> true/false
    #
    # _record_と_other_が同じgroongaのレコードなら+true+を返し、
    # そうでなければ+false+を返す。
    def ==(other)
      self.class == other.class and
        [view, id] == [other.view, other.id]
    end

    # call-seq:
    #   record[column_name] -> 値
    #
    # このレコードの_column_name_で指定されたカラムの値を返す。
    def [](column_name)
      @view.column_value(@id, column_name)
    end

    private
    def method_missing(name, *args, &block)
      return super if /(?:=|\?)\z/ =~ name.to_s
      return super unless args.empty?
      self[name.to_s]
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
rroonga-1.2.9 lib/groonga/view-record.rb
rroonga-1.2.8 lib/groonga/view-record.rb
rroonga-1.2.7-x86-mswin32 lib/groonga/view-record.rb
rroonga-1.2.7-x86-mingw32 lib/groonga/view-record.rb
rroonga-1.2.7 lib/groonga/view-record.rb
rroonga-1.2.6 lib/groonga/view-record.rb
rroonga-1.2.5-x86-mingw32 lib/groonga/view-record.rb
rroonga-1.2.5 lib/groonga/view-record.rb
rroonga-1.2.4 lib/groonga/view-record.rb
rroonga-1.2.3 lib/groonga/view-record.rb
rroonga-1.2.2 lib/groonga/view-record.rb
rroonga-1.2.1 lib/groonga/view-record.rb
rroonga-1.2.0 lib/groonga/view-record.rb
rroonga-1.1.0-x86-mingw32 lib/groonga/view-record.rb
rroonga-1.1.0 lib/groonga/view-record.rb
rroonga-1.0.9 lib/groonga/view-record.rb
rroonga-1.0.8 lib/groonga/view-record.rb
rroonga-1.0.7 lib/groonga/view-record.rb
rroonga-1.0.5 lib/groonga/view-record.rb
rroonga-1.0.4 lib/groonga/view-record.rb