Class: Groonga::Client::Request::Select::ScriptSyntaxExpressionParameter

Inherits:
Object
  • Object
show all
Includes:
ScriptSyntaxValueEscapable
Defined in:
lib/groonga/client/request/select.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, expression, values) ⇒ ScriptSyntaxExpressionParameter

Returns a new instance of ScriptSyntaxExpressionParameter.



801
802
803
804
805
# File 'lib/groonga/client/request/select.rb', line 801

def initialize(name, expression, values)
  @name = name
  @expression = expression
  @values = values
end

Instance Method Details

#to_parametersObject



807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
# File 'lib/groonga/client/request/select.rb', line 807

def to_parameters
  case @expression
  when String
    return {} if /\A\s*\z/ === @expression
    expression = @expression
  when NilClass
    return {}
  else
    expression = @expression
  end

  case @values
  when ::Hash
    escaped_values = {}
    @values.each do |key, value|
      escaped_values[key] = escape_script_syntax_value(value)
    end
    expression = expression % escaped_values
  when ::Array
    escaped_values = @values.collect do |value|
      escape_script_syntax_value(value)
    end
    expression = expression % escaped_values
  end

  {
    @name => expression,
  }
end