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.



1237
1238
1239
# File 'lib/hotdog/commands/search.rb', line 1237

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

Instance Method Details

#condition(options = {}) ⇒ Object



1241
1242
1243
# File 'lib/hotdog/commands/search.rb', line 1241

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



1245
1246
1247
# File 'lib/hotdog/commands/search.rb', line 1245

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

#condition_values(options = {}) ⇒ Object



1249
1250
1251
# File 'lib/hotdog/commands/search.rb', line 1249

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

#maybe_fallback(options = {}) ⇒ Object



1253
1254
1255
1256
1257
1258
1259
1260
1261
# File 'lib/hotdog/commands/search.rb', line 1253

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