Class: Hotdog::Commands::Search::GlobTagNode

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, attribute, separator = nil) ⇒ GlobTagNode



1153
1154
1155
# File 'lib/hotdog/commands/search.rb', line 1153

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

Instance Method Details

#condition(options = {}) ⇒ Object



1157
1158
1159
# File 'lib/hotdog/commands/search.rb', line 1157

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

#condition_tables(options = {}) ⇒ Object



1161
1162
1163
# File 'lib/hotdog/commands/search.rb', line 1161

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

#condition_values(options = {}) ⇒ Object



1165
1166
1167
# File 'lib/hotdog/commands/search.rb', line 1165

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

#maybe_fallback(options = {}) ⇒ Object



1169
1170
1171
1172
1173
1174
1175
1176
1177
# File 'lib/hotdog/commands/search.rb', line 1169

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