Class: Hotdog::Expression::GlobTagNode

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

Instance Attribute Summary

Attributes inherited from TagExpressionNode

#separator, #tag_name, #tag_value

Instance Method Summary collapse

Methods inherited from GlobExpressionNode

#dump

Methods inherited from TagExpressionNode

#==, #dump, #evaluate, #maybe_glob, #maybe_query, #maybe_query_without_condition, #optimize, #reload, #separator?, #tag_name?, #tag_value?, #to_glob

Methods inherited from ExpressionNode

#dump, #evaluate, #optimize

Constructor Details

#initialize(tag_name, tag_value, separator = nil) ⇒ GlobTagNode

Returns a new instance of GlobTagNode.



901
902
903
# File 'lib/hotdog/expression/semantics.rb', line 901

def initialize(tag_name, tag_value, separator=nil)
  super(tag_name.to_s, tag_value.to_s, separator)
end

Instance Method Details

#condition(options = {}) ⇒ Object



905
906
907
# File 'lib/hotdog/expression/semantics.rb', line 905

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

#condition_tables(options = {}) ⇒ Object



909
910
911
# File 'lib/hotdog/expression/semantics.rb', line 909

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

#condition_values(options = {}) ⇒ Object



913
914
915
# File 'lib/hotdog/expression/semantics.rb', line 913

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

#maybe_fallback(options = {}) ⇒ Object



917
918
919
920
921
922
923
924
925
# File 'lib/hotdog/expression/semantics.rb', line 917

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