Class: Hotdog::Expression::GlobTagValueNode

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_value, separator = nil) ⇒ GlobTagValueNode

Returns a new instance of GlobTagValueNode.



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

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

Instance Method Details

#condition(options = {}) ⇒ Object



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

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

#condition_tables(options = {}) ⇒ Object



965
966
967
# File 'lib/hotdog/expression/semantics.rb', line 965

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

#condition_values(options = {}) ⇒ Object



969
970
971
# File 'lib/hotdog/expression/semantics.rb', line 969

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

#maybe_fallback(options = {}) ⇒ Object



973
974
975
976
977
978
979
980
981
# File 'lib/hotdog/expression/semantics.rb', line 973

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