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.



1060
1061
1062
# File 'lib/hotdog/commands/search.rb', line 1060

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

Instance Method Details

#condition(options = {}) ⇒ Object



1064
1065
1066
# File 'lib/hotdog/commands/search.rb', line 1064

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

#condition_tables(options = {}) ⇒ Object



1068
1069
1070
# File 'lib/hotdog/commands/search.rb', line 1068

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

#condition_values(options = {}) ⇒ Object



1072
1073
1074
# File 'lib/hotdog/commands/search.rb', line 1072

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

#maybe_fallback(options = {}) ⇒ Object



1076
1077
1078
1079
1080
1081
1082
1083
# File 'lib/hotdog/commands/search.rb', line 1076

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