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.



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

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

Instance Method Details

#condition(options = {}) ⇒ Object



852
853
854
# File 'lib/hotdog/expression/semantics.rb', line 852

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

#condition_tables(options = {}) ⇒ Object



856
857
858
# File 'lib/hotdog/expression/semantics.rb', line 856

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

#condition_values(options = {}) ⇒ Object



860
861
862
# File 'lib/hotdog/expression/semantics.rb', line 860

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

#maybe_fallback(options = {}) ⇒ Object



864
865
866
867
868
869
870
871
872
# File 'lib/hotdog/expression/semantics.rb', line 864

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