Class: Hotdog::Commands::Search::GlobTagValueNode

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



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

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

Instance Method Details

#condition(options = {}) ⇒ Object



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

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

#condition_tables(options = {}) ⇒ Object



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

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

#condition_values(options = {}) ⇒ Object



1221
1222
1223
# File 'lib/hotdog/commands/search.rb', line 1221

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

#maybe_fallback(options = {}) ⇒ Object



1225
1226
1227
1228
1229
1230
1231
1232
1233
# File 'lib/hotdog/commands/search.rb', line 1225

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