Class: Hotdog::Commands::Search::StringTagNode

Inherits:
StringExpressionNode 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 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) ⇒ StringTagNode

Returns a new instance of StringTagNode.



979
980
981
# File 'lib/hotdog/commands/search.rb', line 979

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

Instance Method Details

#condition(options = {}) ⇒ Object



983
984
985
# File 'lib/hotdog/commands/search.rb', line 983

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

#condition_tables(options = {}) ⇒ Object



987
988
989
# File 'lib/hotdog/commands/search.rb', line 987

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

#condition_values(options = {}) ⇒ Object



991
992
993
# File 'lib/hotdog/commands/search.rb', line 991

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

#maybe_fallback(options = {}) ⇒ Object



995
996
997
998
999
1000
1001
1002
# File 'lib/hotdog/commands/search.rb', line 995

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