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.



920
921
922
# File 'lib/hotdog/expression/semantics.rb', line 920

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

Instance Method Details

#condition(options = {}) ⇒ Object



924
925
926
# File 'lib/hotdog/expression/semantics.rb', line 924

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

#condition_tables(options = {}) ⇒ Object



928
929
930
# File 'lib/hotdog/expression/semantics.rb', line 928

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

#condition_values(options = {}) ⇒ Object



932
933
934
# File 'lib/hotdog/expression/semantics.rb', line 932

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

#maybe_fallback(options = {}) ⇒ Object



936
937
938
939
940
941
942
943
944
# File 'lib/hotdog/expression/semantics.rb', line 936

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