Class: Hotdog::Expression::StringTagvalueNode

Inherits:
StringExpressionNode show all
Defined in:
lib/hotdog/expression/semantics.rb

Instance Attribute Summary

Attributes inherited from TagExpressionNode

#separator, #tagname, #tagvalue

Instance Method Summary collapse

Methods inherited from TagExpressionNode

#==, #dump, #evaluate, #maybe_glob, #maybe_query, #maybe_query_without_condition, #optimize, #reload, #separator?, #tagname?, #tagvalue?, #to_glob

Methods inherited from ExpressionNode

#==, #dump, #evaluate, #optimize

Constructor Details

#initialize(tagvalue, separator = nil) ⇒ StringTagvalueNode

Returns a new instance of StringTagvalueNode.



838
839
840
# File 'lib/hotdog/expression/semantics.rb', line 838

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

Instance Method Details

#condition(options = {}) ⇒ Object



842
843
844
# File 'lib/hotdog/expression/semantics.rb', line 842

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

#condition_tables(options = {}) ⇒ Object



846
847
848
# File 'lib/hotdog/expression/semantics.rb', line 846

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

#condition_values(options = {}) ⇒ Object



850
851
852
# File 'lib/hotdog/expression/semantics.rb', line 850

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

#maybe_fallback(options = {}) ⇒ Object



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

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