Class: Hotdog::Expression::StringTagNode

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_name, tag_value, separator = nil) ⇒ StringTagNode

Returns a new instance of StringTagNode.



750
751
752
# File 'lib/hotdog/expression/semantics.rb', line 750

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

Instance Method Details

#condition(options = {}) ⇒ Object



754
755
756
# File 'lib/hotdog/expression/semantics.rb', line 754

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

#condition_tables(options = {}) ⇒ Object



758
759
760
# File 'lib/hotdog/expression/semantics.rb', line 758

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

#condition_values(options = {}) ⇒ Object



762
763
764
# File 'lib/hotdog/expression/semantics.rb', line 762

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

#maybe_fallback(options = {}) ⇒ Object



766
767
768
769
770
771
772
773
774
# File 'lib/hotdog/expression/semantics.rb', line 766

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