class Lookbook::PreviewCollection

def self.preview_from_code_object(code_object)

def self.preview_from_code_object(code_object)
  klass = code_object.path.constantize
  Preview.new(code_object) if klass.ancestors.include?(ViewComponent::Preview)
rescue => exception
  Lookbook.logger.error LookbookError.new(exception)
  nil
end

def examples

def examples
  @_cache[:examples] ||= PreviewExampleCollection.new(flat_map(&:examples))
end

def find_by_preview_class(klass)

def find_by_preview_class(klass)
  find { |preview| preview.preview_class.name == klass.to_s }
end

def find_example_by_path(lookup_path)

def find_example_by_path(lookup_path)
  examples.find_by_path(lookup_path)
end

def load(code_objects)

def load(code_objects)
  @entities = []
  clear_cache
  previews = Array(code_objects).map { |obj| PreviewCollection.preview_from_code_object(obj) }.compact
  add(previews)
end