Sha256: f7e776b2477bc501e11703f1fcf976fdfd35d22868bfdca25dce174852631eac

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 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
      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

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-1.0.0.beta.1 lib/lookbook/preview_group.rb
lookbook-1.0.0.beta.0 lib/lookbook/preview_group.rb