Class: Hotdog::Expression::StringTagValueNode

Inherits:
StringExpressionNode 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 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) ⇒ StringTagValueNode

Returns a new instance of StringTagValueNode.



806
807
808
# File 'lib/hotdog/expression/semantics.rb', line 806

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

Instance Method Details

#condition(options = {}) ⇒ Object



810
811
812
# File 'lib/hotdog/expression/semantics.rb', line 810

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

#condition_tables(options = {}) ⇒ Object



814
815
816
# File 'lib/hotdog/expression/semantics.rb', line 814

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

#condition_values(options = {}) ⇒ Object



818
819
820
# File 'lib/hotdog/expression/semantics.rb', line 818

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

#maybe_fallback(options = {}) ⇒ Object



822
823
824
825
826
827
828
829
830
# File 'lib/hotdog/expression/semantics.rb', line 822

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