Class: Hotdog::Commands::Search::StringNode

Inherits:
StringExpressionNode show all
Defined in:
lib/hotdog/commands/search.rb

Instance Attribute Summary

Attributes inherited from TagExpressionNode

#attribute, #identifier, #separator

Instance Method Summary collapse

Methods inherited from TagExpressionNode

#==, #attribute?, #dump, #evaluate, #identifier?, #maybe_glob, #maybe_query, #maybe_query_without_condition, #optimize, #reload, #separator?, #to_glob

Methods inherited from ExpressionNode

#dump, #evaluate, #intermediates, #leafs, #optimize

Constructor Details

#initialize(identifier, separator = nil) ⇒ StringNode

Returns a new instance of StringNode.



1086
1087
1088
# File 'lib/hotdog/commands/search.rb', line 1086

def initialize(identifier, separator=nil)
  super(identifier, nil, separator)
end

Instance Method Details

#condition(options = {}) ⇒ Object



1090
1091
1092
# File 'lib/hotdog/commands/search.rb', line 1090

def condition(options={})
  "hosts.name = ? OR tags.name = ? OR tags.value = ?"
end

#condition_tables(options = {}) ⇒ Object



1094
1095
1096
# File 'lib/hotdog/commands/search.rb', line 1094

def condition_tables(options={})
  [:hosts, :tags]
end

#condition_values(options = {}) ⇒ Object



1098
1099
1100
# File 'lib/hotdog/commands/search.rb', line 1098

def condition_values(options={})
  [identifier, identifier, identifier]
end

#maybe_fallback(options = {}) ⇒ Object



1102
1103
1104
1105
1106
1107
1108
1109
1110
# File 'lib/hotdog/commands/search.rb', line 1102

def maybe_fallback(options={})
  fallback = GlobNode.new(to_glob(identifier), separator)
  query = fallback.maybe_query(options)
  if query
    QueryExpressionNode.new(query, fallback.condition_values(options))
  else
    nil
  end
end