Method: Primer::Yard::ComponentManifest.where

Defined in:
lib/primer/yard/component_manifest.rb

.where(components = COMPONENTS, **desired_attrs) ⇒ Object

[View source]

121
122
123
124
125
126
127
128
129
130
131
# File 'lib/primer/yard/component_manifest.rb', line 121

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