Class: Groonga::Command::Base
- Inherits:
-
Object
- Object
- Groonga::Command::Base
show all
- Defined in:
- lib/groonga/command/base.rb
Direct Known Subclasses
ColumnCopy, ColumnCreate, ColumnCreateSimilar, ColumnList, ColumnRemove, ColumnRename, ConfigDelete, ConfigGet, ConfigSet, Delete, Dump, Get, IOFlush, IndexColumnDiff, Load, LogLevel, LogPut, LogicalCount, LogicalRangeFilter, LogicalSelect, LogicalShardList, LogicalTableRemove, Normalize, ObjectExist, ObjectInspect, ObjectRemove, PluginRegister, PluginUnregister, QueryExpand, QueryLogFlagsAdd, QueryLogFlagsGet, QueryLogFlagsRemove, QueryLogFlagsSet, RangeFilter, ReferenceAcquire, ReferenceRelease, Register, Reindex, RequestCancel, RubyEval, RubyLoad, Schema, Select, Shutdown, Status, Suggest, TableCopy, TableCreate, TableCreateSimilar, TableList, TableRemove, TableRename, TableTokenize, ThreadLimit, Tokenize, Truncate
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(pair_arguments, ordered_arguments = {}) ⇒ Base
#initialize(command_name, pair_arguments, ordered_arguments = {}) ⇒ Base
Returns a new instance of Base.
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/groonga/command/base.rb', line 85
def initialize(arg1=nil, arg2=nil, arg3=nil)
case arg1
when String, Symbol
command_name = arg1.to_s
pair_arguments = arg2
ordered_arguments = arg3
else
command_name = self.class.command_name
pair_arguments = arg1
ordered_arguments = arg2
end
pair_arguments ||= {}
ordered_arguments ||= []
@command_name = command_name
@arguments = construct_arguments(pair_arguments, ordered_arguments)
@original_format = nil
@original_source = nil
@path_prefix = "/d/"
end
|
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
60
61
62
|
# File 'lib/groonga/command/base.rb', line 60
def arguments
@arguments
end
|
#command_name ⇒ String
Returns The command name.
59
60
61
|
# File 'lib/groonga/command/base.rb', line 59
def command_name
@command_name
end
|
Returns the value of attribute original_format.
61
62
63
|
# File 'lib/groonga/command/base.rb', line 61
def original_format
@original_format
end
|
#original_source ⇒ Object
Returns the value of attribute original_source.
61
62
63
|
# File 'lib/groonga/command/base.rb', line 61
def original_source
@original_source
end
|
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
61
62
63
|
# File 'lib/groonga/command/base.rb', line 61
def path_prefix
@path_prefix
end
|
Class Method Details
.parameter_names ⇒ Object
51
52
53
|
# File 'lib/groonga/command/base.rb', line 51
def parameter_names
[]
end
|
Instance Method Details
#==(other) ⇒ Object
124
125
126
127
128
|
# File 'lib/groonga/command/base.rb', line 124
def ==(other)
other.is_a?(self.class) and
@command_name == other.command_name and
@arguments == other.arguments
end
|
#[](name) ⇒ Object
111
112
113
|
# File 'lib/groonga/command/base.rb', line 111
def [](name)
@arguments[normalize_name(name)]
end
|
#[]=(name, value) ⇒ Object
115
116
117
|
# File 'lib/groonga/command/base.rb', line 115
def []=(name, value)
@arguments[normalize_name(name)] = value
end
|
134
135
136
|
# File 'lib/groonga/command/base.rb', line 134
def command_format?
@original_format == :command
end
|
#key?(name) ⇒ Boolean
Also known as:
has_key?
119
120
121
|
# File 'lib/groonga/command/base.rb', line 119
def key?(name)
@arguments.key?(normalize_name(name))
end
|
#name ⇒ Object
107
108
109
|
# File 'lib/groonga/command/base.rb', line 107
def name
command_name
end
|
#output_trace_log? ⇒ Boolean
Returns output_trace_log parameter value.
152
153
154
|
# File 'lib/groonga/command/base.rb', line 152
def output_trace_log?
boolean_value(:output_trace_log, default: false, invalid: false)
end
|
#output_type ⇒ Object
138
139
140
|
# File 'lib/groonga/command/base.rb', line 138
def output_type
(self[:output_type] || :json).to_sym
end
|
#request_id ⇒ String?
Returns request_id parameter value.
145
146
147
|
# File 'lib/groonga/command/base.rb', line 145
def request_id
self[:request_id]
end
|
160
161
162
163
|
# File 'lib/groonga/command/base.rb', line 160
def to_command_format(options={})
format = Format::Command.new(@command_name, normalized_arguments)
format.command_line(options)
end
|
165
166
167
168
|
# File 'lib/groonga/command/base.rb', line 165
def to_elasticsearch_format(options={})
format = Format::Elasticsearch.new(self)
format.json(options)
end
|
#to_s ⇒ Object
170
171
172
173
174
175
176
|
# File 'lib/groonga/command/base.rb', line 170
def to_s
if uri_format?
to_uri_format
else
to_command_format
end
end
|
156
157
158
|
# File 'lib/groonga/command/base.rb', line 156
def to_uri_format
Format::URI.new(@path_prefix, @command_name, normalized_arguments).path
end
|
130
131
132
|
# File 'lib/groonga/command/base.rb', line 130
def uri_format?
@original_format == :uri
end
|