Sha256: 347b074d4779c8ac25da62fb31e9e210aaf03fee3c7de92e2b9ca9da90f17095

Contents?: true

Size: 911 Bytes

Versions: 5

Compression:

Stored size: 911 Bytes

Contents

module Lookbook
  class PreviewGroup < Entity
    attr_reader :name, :examples, :preview

    def initialize(name, preview, examples)
      @name = name
      @preview = preview
      @examples = examples
      super("#{@preview.path}/#{name}")
    end

    def url_path
      lookbook_inspect_path lookup_path
    end

    def label
      name.titleize
    end

    def type
      :group
    end

    def params
      examples.map(&:params).flatten.uniq { |param| param[:name] }
    end

    def display_params
      merged = {}
      examples.reverse.map do |example|
        merged.merge! example.display_params
      end
      merged
    end

    def hidden?
      false
    end

    def position
      10000
    end

    def matchers
      normalize_matchers(@preview.label, label)
    end

    def hierarchy_depth
      @preview.hierarchy_depth + 1
    end

    alias_method :lookup_path, :path
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lookbook-1.0.0.beta.6 lib/lookbook/preview_group.rb
lookbook-1.0.0.beta.5 lib/lookbook/preview_group.rb
lookbook-1.0.0.beta.4 lib/lookbook/preview_group.rb
lookbook-1.0.0.beta.3 lib/lookbook/preview_group.rb
lookbook-1.0.0.beta.2 lib/lookbook/preview_group.rb