Class: Hotdog::Commands::Search::StringHostNode

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) ⇒ StringHostNode

Returns a new instance of StringHostNode.



974
975
976
# File 'lib/hotdog/commands/search.rb', line 974

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

Instance Method Details

#condition(options = {}) ⇒ Object



978
979
980
# File 'lib/hotdog/commands/search.rb', line 978

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

#condition_tables(options = {}) ⇒ Object



982
983
984
# File 'lib/hotdog/commands/search.rb', line 982

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

#condition_values(options = {}) ⇒ Object



986
987
988
# File 'lib/hotdog/commands/search.rb', line 986

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

#maybe_fallback(options = {}) ⇒ Object



990
991
992
993
994
995
996
997
998
# File 'lib/hotdog/commands/search.rb', line 990

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