Sha256: d8cdfc357f232519b5d0a323a4fd2a1738b4aca8f38f90742168c2cae8bf6cf6
Contents?: true
Size: 1.92 KB
Versions: 8
Compression:
Stored size: 1.92 KB
Contents
# Copyright (C) 2016 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 as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA module Groonga class Client class Searcher class Source attr_reader :model_class attr_reader :columns def initialize(schema, model_class) @schema = schema @model_class = model_class @columns = {} end def []=(name, reader) unless @schema.have_column?(name) message = "unknown column name: #{name.inspect}" available_columns = @schema.columns.keys.join(", ") message << "available columns: [#{available_columns}]" raise ArgumentError, message end @columns[name.to_s] = reader end def method_missing(name, *args, &block) return super unless name.to_s.end_with?("=") base_name = name.to_s[0..-2] if @schema.have_column?(base_name) __send__(:[]=, base_name, *args, &block) else super end end def respond_to_missing?(name, include_private) return super unless name.to_s.end_with?("=") base_name = name.to_s[0..-2] @schema.have_column?(base_name) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems