Class: Hotdog::Expression::GlobHostNode

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) ⇒ GlobHostNode

Returns a new instance of GlobHostNode.



836
837
838
# File 'lib/hotdog/expression/semantics.rb', line 836

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

Instance Method Details

#condition(options = {}) ⇒ Object



840
841
842
# File 'lib/hotdog/expression/semantics.rb', line 840

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

#condition_tables(options = {}) ⇒ Object



844
845
846
# File 'lib/hotdog/expression/semantics.rb', line 844

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

#condition_values(options = {}) ⇒ Object



848
849
850
# File 'lib/hotdog/expression/semantics.rb', line 848

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

#maybe_fallback(options = {}) ⇒ Object



852
853
854
855
856
857
858
859
860
# File 'lib/hotdog/expression/semantics.rb', line 852

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