Sha256: 07eadcc9f0761bf9820063471df487a02da71b86a3e8d1e5bd3bbc66dd54f093

Contents?: true

Size: 910 Bytes

Versions: 4

Compression:

Stored size: 910 Bytes

Contents

module Lookbook
  # @api private
  module NavigableEntity
    extend ActiveSupport::Concern

    included do
      def hidden?
        fetch_config(:hidden, false)
      end

      def visible?
        !hidden?
      end

      def priority
        return @_priority if @_priority

        pos = if @priority_prefixes && respond_to?(:file_name)
          PriorityPrefixParser.call(file_name).first || fetch_config(:priority, default_priority)
        else
          fetch_config(:priority, default_priority)
        end

        @_priority ||= pos.to_i
      end

      def depth
        lookup_path.split("/").size
      end

      def default_priority
        @default_priority || 10000
      end

      def <=>(other)
        if respond_to?(:sort_handler, true)
          sort_handler(other)
        else
          [priority, label] <=> [other.priority, other.label]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lookbook-2.0.0.beta.3 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.beta.2 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.beta.1 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.beta.0 lib/lookbook/entities/concerns/navigable_entity.rb