Class: CloudSesame::Query::AST::Literal

Inherits:
SingleBranch show all
Defined in:
lib/cloud_sesame/query/ast/literal.rb

Instance Attribute Summary collapse

Attributes inherited from SingleBranch

#child, #context

Instance Method Summary collapse

Methods inherited from SingleBranch

#<<

Constructor Details

#initialize(field = nil, value = nil, options = {}) ⇒ Literal

Returns a new instance of Literal.



9
10
11
12
13
# File 'lib/cloud_sesame/query/ast/literal.rb', line 9

def initialize(field = nil, value = nil, options = {})
  @field = field
  @value = to_value value
  ((@options = options || {})[:included] ||= []) << @value
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



6
7
8
# File 'lib/cloud_sesame/query/ast/literal.rb', line 6

def field
  @field
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/cloud_sesame/query/ast/literal.rb', line 7

def options
  @options
end

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/cloud_sesame/query/ast/literal.rb', line 7

def value
  @value
end

Instance Method Details

#as_fieldObject



15
16
17
# File 'lib/cloud_sesame/query/ast/literal.rb', line 15

def as_field
  options[:as] || field
end

#compileObject



19
20
21
# File 'lib/cloud_sesame/query/ast/literal.rb', line 19

def compile
  options[:detailed] ? detailed_format : standard_format
end

#detailedObject



23
24
25
26
# File 'lib/cloud_sesame/query/ast/literal.rb', line 23

def detailed
  options[:detailed] = true
  return self
end