Class: Hotdog::Commands::Search::GlobNode

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(identifier, separator = nil) ⇒ GlobNode

Returns a new instance of GlobNode.



1206
1207
1208
# File 'lib/hotdog/commands/search.rb', line 1206

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

Instance Method Details

#condition(options = {}) ⇒ Object



1210
1211
1212
# File 'lib/hotdog/commands/search.rb', line 1210

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

#condition_tables(options = {}) ⇒ Object



1214
1215
1216
# File 'lib/hotdog/commands/search.rb', line 1214

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

#condition_values(options = {}) ⇒ Object



1218
1219
1220
# File 'lib/hotdog/commands/search.rb', line 1218

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

#maybe_fallback(options = {}) ⇒ Object



1222
1223
1224
1225
1226
1227
1228
1229
# File 'lib/hotdog/commands/search.rb', line 1222

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