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.



876
877
878
# File 'lib/hotdog/expression/semantics.rb', line 876

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



880
881
882
# File 'lib/hotdog/expression/semantics.rb', line 880

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

#condition_tables(options = {}) ⇒ Object



884
885
886
# File 'lib/hotdog/expression/semantics.rb', line 884

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

#condition_values(options = {}) ⇒ Object



888
889
890
# File 'lib/hotdog/expression/semantics.rb', line 888

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

#maybe_fallback(options = {}) ⇒ Object



892
893
894
895
896
897
898
899
900
# File 'lib/hotdog/expression/semantics.rb', line 892

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