Class: Hotdog::Expression::GlobTagNameNode

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

Returns a new instance of GlobTagNameNode.



929
930
931
# File 'lib/hotdog/expression/semantics.rb', line 929

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

Instance Method Details

#condition(options = {}) ⇒ Object



933
934
935
# File 'lib/hotdog/expression/semantics.rb', line 933

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

#condition_tables(options = {}) ⇒ Object



937
938
939
# File 'lib/hotdog/expression/semantics.rb', line 937

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

#condition_values(options = {}) ⇒ Object



941
942
943
# File 'lib/hotdog/expression/semantics.rb', line 941

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

#maybe_fallback(options = {}) ⇒ Object



945
946
947
948
949
950
951
952
953
# File 'lib/hotdog/expression/semantics.rb', line 945

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