Class: Groonga::Client::Response::Schema

Inherits:
Base
  • Object
show all
Defined in:
lib/groonga/client/response/schema.rb

Overview

The response class for schema command.

Since:

  • 0.2.2

Defined Under Namespace

Modules: HashValueConverter Classes: Column, Command, Index, KeyType, Normalizer, Plugin, Table, TokenFilter, Tokenizer, Type, ValueType

Instance Attribute Summary

Attributes inherited from Base

#body, #command, #header, #raw, #trace_logs

Instance Method Summary collapse

Methods inherited from Base

#elapsed_time, #error_message, #initialize, parse, #return_code, #start_time, #status_code, #success?

Constructor Details

This class inherits a constructor from Groonga::Client::Response::Base

Instance Method Details

#[](name) ⇒ Plugin, ...

Returns The object named name.

Parameters:

  • name (String)

    The object name to be retrieved.

Returns:

Since:

  • 0.5.3



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/groonga/client/response/schema.rb', line 105

def [](name)
  name = name.to_s if name.is_a?(Symbol)
  if name.include?(".")
    table_name, column_name = name.split(".", 2)
    tables[table_name].columns[column_name]
  else
    tables[name] ||
      types[name] ||
      tokenizers[name] ||
      normalizers[name] ||
      token_filters[name] ||
      plugins[name]
  end
end

#normalizersHash<String, Normalizer>

Returns Key is normalizer name and value is the definition of the normalizer.

Returns:

  • (Hash<String, Normalizer>)

    Key is normalizer name and value is the definition of the normalizer.

Since:

  • 0.2.3



62
63
64
65
66
# File 'lib/groonga/client/response/schema.rb', line 62

def normalizers
  @normalizers ||= HashValueConverter.convert(@body["normalizers"]) do |normalizer|
    Normalizer[normalizer]
  end
end

#pluginsHash<String, Plugin>

Returns Key is plugin name and value is the definition of the plugin.

Returns:

  • (Hash<String, Plugin>)

    Key is plugin name and value is the definition of the plugin.

Since:

  • 0.3.6



32
33
34
35
36
# File 'lib/groonga/client/response/schema.rb', line 32

def plugins
  @plugins ||= HashValueConverter.convert(@body["plugins"]) do |raw_plugin|
    Plugin[raw_plugin]
  end
end

#tablesHash<String, Table>

Returns Key is table name and value is the definition of the table.

Returns:

  • (Hash<String, Table>)

    Key is table name and value is the definition of the table.

Since:

  • 0.2.2



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/groonga/client/response/schema.rb', line 82

def tables
  @tables ||= nil
  return @tables if @tables

  @tables = {}
  @body["tables"].each do |key, _|
    @tables[key] = Table.new(self)
  end
  @body["tables"].each do |key, raw_table|
    table = @tables[key]
    raw_table.each do |table_key, table_value|
      table[table_key] = table_value
    end
  end
  @tables
end

#token_filtersHash<String, TokenFilter>

Returns Key is token filter name and value is the definition of the token filter.

Returns:

  • (Hash<String, TokenFilter>)

    Key is token filter name and value is the definition of the token filter.

Since:

  • 0.2.3



72
73
74
75
76
# File 'lib/groonga/client/response/schema.rb', line 72

def token_filters
  @token_filters ||= HashValueConverter.convert(@body["token_filters"]) do |token_filter|
    TokenFilter[token_filter]
  end
end

#tokenizersHash<String, Tokenizer>

Returns Key is tokenizer name and value is the definition of the tokenizer.

Returns:

  • (Hash<String, Tokenizer>)

    Key is tokenizer name and value is the definition of the tokenizer.

Since:

  • 0.2.2



52
53
54
55
56
# File 'lib/groonga/client/response/schema.rb', line 52

def tokenizers
  @tokenizers ||= HashValueConverter.convert(@body["tokenizers"]) do |tokenizer|
    Tokenizer[tokenizer]
  end
end

#typesHash<String, Type>

Returns Key is type name and value is the definition of the type.

Returns:

  • (Hash<String, Type>)

    Key is type name and value is the definition of the type.

Since:

  • 0.2.2



42
43
44
45
46
# File 'lib/groonga/client/response/schema.rb', line 42

def types
  @types ||= HashValueConverter.convert(@body["types"]) do |raw_type|
    Type[raw_type]
  end
end