Class: Hotdog::Expression::GlobTagNode

Inherits:
GlobExpressionNode show all
Defined in:
lib/hotdog/expression/semantics.rb

Instance Attribute Summary

Attributes inherited from TagExpressionNode

#separator, #tagname, #tagvalue

Instance Method Summary collapse

Methods inherited from GlobExpressionNode

#dump

Methods inherited from TagExpressionNode

#==, #dump, #evaluate, #maybe_glob, #maybe_query, #maybe_query_without_condition, #optimize, #separator?, #tagname?, #tagvalue?, #to_glob

Methods inherited from ExpressionNode

#==, #compact, #dump, #evaluate, #optimize

Constructor Details

#initialize(tagname, tagvalue, separator = nil, options = {}) ⇒ GlobTagNode

Returns a new instance of GlobTagNode.



948
949
950
# File 'lib/hotdog/expression/semantics.rb', line 948

def initialize(tagname, tagvalue, separator=nil, options={})
  super(tagname.to_s, tagvalue.to_s, separator, options)
end

Instance Method Details

#condition(options = {}) ⇒ Object



952
953
954
# File 'lib/hotdog/expression/semantics.rb', line 952

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

#condition_tables(options = {}) ⇒ Object



956
957
958
# File 'lib/hotdog/expression/semantics.rb', line 956

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

#condition_values(options = {}) ⇒ Object



960
961
962
# File 'lib/hotdog/expression/semantics.rb', line 960

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

#maybe_fallback(options = {}) ⇒ Object



964
965
966
967
968
969
970
971
972
# File 'lib/hotdog/expression/semantics.rb', line 964

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