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.



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

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

Instance Method Details

#condition(options = {}) ⇒ Object



936
937
938
# File 'lib/hotdog/expression/semantics.rb', line 936

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

#condition_tables(options = {}) ⇒ Object



940
941
942
# File 'lib/hotdog/expression/semantics.rb', line 940

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

#condition_values(options = {}) ⇒ Object



944
945
946
# File 'lib/hotdog/expression/semantics.rb', line 944

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

#maybe_fallback(options = {}) ⇒ Object



948
949
950
951
952
953
954
955
956
# File 'lib/hotdog/expression/semantics.rb', line 948

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