class Primer::Yard::ComponentManifest

The set of documented components (and associated metadata).

def all

def all
  new(COMPONENTS.keys)
end

def each

def each
  return to_enum(__method__) unless block_given?
  @components.each do |klass|
    yield self.class.ref_for(klass)
  end
end

def initialize(components)

def initialize(components)
  @components = components
end

def ref_cache

def ref_cache
  @ref_cache ||= {}
end

def ref_for(klass)

def ref_for(klass)
  ref_cache[klass] ||= ComponentRef.new(klass, COMPONENTS.fetch(klass, {}))
end

def where(**attrs)

def where(**attrs)
  self.class.where(@components, **attrs)
end

def where(components = COMPONENTS, **desired_attrs)

def where(components = COMPONENTS, **desired_attrs)
  new(
    components.each_with_object([]) do |(klass, component_attrs), memo|
      matches = desired_attrs.all? do |name, desired_value|
        component_attrs.fetch(name, ComponentRef::ATTR_DEFAULTS[name]) == desired_value
      end
      memo << klass if matches
    end
  )
end