Class: Hotdog::Commands::Search::StringTagValueNode

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(attribute, separator = nil) ⇒ StringTagValueNode



1033
1034
1035
# File 'lib/hotdog/commands/search.rb', line 1033

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

Instance Method Details

#condition(options = {}) ⇒ Object



1037
1038
1039
# File 'lib/hotdog/commands/search.rb', line 1037

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

#condition_tables(options = {}) ⇒ Object



1041
1042
1043
# File 'lib/hotdog/commands/search.rb', line 1041

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

#condition_values(options = {}) ⇒ Object



1045
1046
1047
# File 'lib/hotdog/commands/search.rb', line 1045

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

#maybe_fallback(options = {}) ⇒ Object



1049
1050
1051
1052
1053
1054
1055
1056
# File 'lib/hotdog/commands/search.rb', line 1049

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