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.



864
865
866
# File 'lib/hotdog/expression/semantics.rb', line 864

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



868
869
870
# File 'lib/hotdog/expression/semantics.rb', line 868

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

#condition_tables(options = {}) ⇒ Object



872
873
874
# File 'lib/hotdog/expression/semantics.rb', line 872

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

#condition_values(options = {}) ⇒ Object



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

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

#maybe_fallback(options = {}) ⇒ Object



880
881
882
883
884
885
886
887
888
# File 'lib/hotdog/expression/semantics.rb', line 880

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