Module: AttrSearchableGrammar::Nodes::Base

Included in:
Binary, Collection, FulltextExpression, MatchesFulltext, Not
Defined in:
lib/attr_searchable_grammar/nodes.rb

Instance Method Summary collapse

Instance Method Details

#and(node) ⇒ Object



7
8
9
# File 'lib/attr_searchable_grammar/nodes.rb', line 7

def and(node)
  And.new self, node
end

#can_flatten?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/attr_searchable_grammar/nodes.rb', line 19

def can_flatten?
  false
end

#can_group?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/attr_searchable_grammar/nodes.rb', line 27

def can_group?
  false
end

#can_optimize?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/attr_searchable_grammar/nodes.rb', line 39

def can_optimize?
  can_flatten? || can_group?
end

#finalize!Object



53
54
55
# File 'lib/attr_searchable_grammar/nodes.rb', line 53

def finalize!
  self
end

#flatten!Object



23
24
25
# File 'lib/attr_searchable_grammar/nodes.rb', line 23

def flatten!
  self
end

#fulltext?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/attr_searchable_grammar/nodes.rb', line 35

def fulltext?
  false
end

#group!Object



31
32
33
# File 'lib/attr_searchable_grammar/nodes.rb', line 31

def group!
  self
end

#nodesObject



57
58
59
# File 'lib/attr_searchable_grammar/nodes.rb', line 57

def nodes
  []
end

#notObject



15
16
17
# File 'lib/attr_searchable_grammar/nodes.rb', line 15

def not
  Not.new self
end

#optimize!Object



43
44
45
46
47
# File 'lib/attr_searchable_grammar/nodes.rb', line 43

def optimize!
  flatten!.group! while can_optimize?

  finalize!
end

#or(node) ⇒ Object



11
12
13
# File 'lib/attr_searchable_grammar/nodes.rb', line 11

def or(node)
  Or.new self, node
end

#to_sql(model) ⇒ Object



49
50
51
# File 'lib/attr_searchable_grammar/nodes.rb', line 49

def to_sql(model)
  model.connection.visitor.accept self
end