Class: Groonga::Context
- Inherits:
-
Object
- Object
- Groonga::Context
- Defined in:
- ext/groonga/rb-grn-context.c,
lib/groonga/context.rb
Overview
groonga全体に渡る情報を管理するオブジェクト。通常のアプリ ケーションでは1つのコンテキストを作成し、それを利用する。 複数のコンテキストを利用する必要はない。
デフォルトで使用されるコンテキストは Groonga::Context#defaultでアクセスできる。コンテキストを 指定できる箇所でコンテキストの指定を省略したり nil
を指定 した場合はGroonga::Context.defaultが利用される。
また、デフォルトのコンテキストは必要になると暗黙のうちに 作成される。そのため、コンテキストを意識することは少ない。
暗黙のうちに作成されるコンテキストにオプションを指定する 場合はGroonga::Context.default_options=を使用する。
Instance Method Summary collapse
-
#create_database(path = nil) ⇒ Object
path に新しくデータベースを作成する。 path を省略すると 一時データベースとなる。.
-
#open_database(path, &block) ⇒ Object
path にある既存のデータベースを開く。ブロックを指定した場 合はブロックに開いたデータベースを渡し、ブロックを抜けると きに閉じる。.
-
#register_plugin(name_or_options) ⇒ Object
groongaのプラグインディレクトリにあるプラグイン name を登録する。 path を指定するとプラグインディレクトリ以 外にあるプラグインを登録することができる。.
-
#select(table, options = {}) ⇒ Object
table から指定した条件にマッチするレコードの値を取得 する。 table はテーブル名かテーブルオブジェクトを指定 する。.
Instance Method Details
#create_database(path = nil) ⇒ Object
path に新しくデータベースを作成する。 path を省略すると 一時データベースとなる。
40 41 42 43 44 45 46 47 |
# File 'lib/groonga/context.rb', line 40 def create_database(path=nil) = {:context => self} if path [:path] = path end Database.create() end |
#open_database(path, &block) ⇒ Object
path にある既存のデータベースを開く。ブロックを指定した場 合はブロックに開いたデータベースを渡し、ブロックを抜けると きに閉じる。
25 26 27 28 29 |
# File 'lib/groonga/context.rb', line 25 def open_database(path, &block) = {:context => self} Database.open(path, , &block) end |
#register_plugin(name_or_options) ⇒ Object
groongaのプラグインディレクトリにあるプラグイン name を登録する。 path を指定するとプラグインディレクトリ以 外にあるプラグインを登録することができる。
52 53 54 55 56 57 58 59 60 |
# File 'lib/groonga/context.rb', line 52 def register_plugin() = {:context => self} if .is_a?(String) name = Plugin.register(name, ) else Plugin.register(.merge()) end end |