diff --git a/lib/comfpile/context.rb b/lib/comfpile/context.rb index 41af118..bfab9e7 100644 --- a/lib/comfpile/context.rb +++ b/lib/comfpile/context.rb @@ -1,59 +1,19 @@ module Comfpile - class ContextTag - attr_reader :tag, :taglist + class ContextKey + attr_reader :provider, :context_hash, :context_symbol - def self.form_context(tag) - @known_tags ||= {} + def initialize(provider, ctx_hash, ctx_symbol) + @provider = provider - case tag - when Symbol - tag_instance = @known_tags[tag] - - return tag_instance unless tag_instance.nil? - - tag_instance = ContextTag.new(tag) - tag_instance = (@known_tags[tag_instance] ||= tag_instance) - - @known_tags[tag] ||= tag_instance - @known_tags[tag_instance.tag] ||= tag_instance - end + @context_hash = ctx_hash + @context_symbol = ctx_symbol end - def initialize(tag) - process_tag(tag) + def to_s + "CTX[" + @context_symbol.to_s + "]" end - - private def process_tag(tag) - case tag - when Symbol, String - @taglist = tag.to_s.split('_').uniq.sort - when Array - @taglist = tag.map(&:to_s).uniq.sort - end - - @tag = @taglist.join('_').to_sym - @taghash = {} - @taglist.each do |tag| - @taghash[tag] = true - end - end - - def include?(*tags) - tags = tags - @tag_array - - tags.empy? - end - alias include_all? include? - - def include_any?(*tags) - tags = tags & @tag_array - - tags.empty? - end - - end #