fix: 🔀 [fixed some of the by-me-caused merge issues]

This commit is contained in:
David Bailey 2023-08-12 20:50:02 +02:00
parent 3c7f48016d
commit 51509ff071

View file

@ -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
#