Class: Hotdog::Commands::Search::GlobHostNode

Inherits:
GlobExpressionNode 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 GlobExpressionNode

#dump

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

Returns a new instance of GlobHostNode.



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

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

Instance Method Details

#condition(options = {}) ⇒ Object



1102
1103
1104
# File 'lib/hotdog/commands/search.rb', line 1102

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

#condition_tables(options = {}) ⇒ Object



1106
1107
1108
# File 'lib/hotdog/commands/search.rb', line 1106

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

#condition_values(options = {}) ⇒ Object



1110
1111
1112
# File 'lib/hotdog/commands/search.rb', line 1110

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

#maybe_fallback(options = {}) ⇒ Object



1114
1115
1116
1117
1118
1119
1120
1121
# File 'lib/hotdog/commands/search.rb', line 1114

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