Sha256: 47a2a477fd8d3a61c8e419c3bfa9ec17cde2c20d8d5c26510de543d30ce232c8

Contents?: true

Size: 1.36 KB

Versions: 23

Compression:

Stored size: 1.36 KB

Contents

module Lookbook
  module NavigableEntity
    extend ActiveSupport::Concern

    included do
      # @!group Visibility

      # Whether or not the entity is hidden (i.e. hidden from navigation)
      #
      # @return [Boolean] true if hidden
      def hidden?
        fetch_config(:hidden, false)
      end

      # Whether or not the entity is visible (i.e. present in navigation)
      #
      # @return [Boolean] true if visible
      def visible?
        !hidden?
      end

      # @!endgroup

      # @api private
      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 ||= @_fallback_priority || pos.to_i
      end

      # @api private
      def default_priority=(i)
        @default_priority = i.to_i
      end

      # @api private
      def depth
        lookup_path.split("/").size
      end

      # @api private
      def default_priority
        @default_priority || 10000
      end

      # @api private
      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

23 entries across 23 versions & 1 rubygems

Version Path
lookbook-2.3.4 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.3.3 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.3.2 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.3.0 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.2.2 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.2.1 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.2.0 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.1.1 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.1.0 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.5 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.4 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.3 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.2 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.1 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.rc.3 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.rc.2 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.rc.1 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.beta.9 lib/lookbook/entities/concerns/navigable_entity.rb
lookbook-2.0.0.beta.8 lib/lookbook/entities/concerns/navigable_entity.rb