Sha256: 1b7877c48ede77e20cc2145779f6c5050a9fdce3d9d2f993eee238ccfccc3582

Contents?: true

Size: 855 Bytes

Versions: 11

Compression:

Stored size: 855 Bytes

Contents

module Lookbook
  module Navigable
    extend ActiveSupport::Concern

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

      def visible?
        !hidden?
      end

      def position
        return @_position if @_position

        pos = if @position_prefixes && respond_to?(:file_name)
          PositionPrefixParser.call(file_name).first || default_position
        else
          fetch_config(:position, default_position)
        end

        @_position ||= pos.to_i
      end

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

      def default_position
        @default_position || 10000
      end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lookbook-1.5.5 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.5.4 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.5.3 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.5.2 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.5.1 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.5.0 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.4.5 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.4.4 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.4.3 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.4.2 lib/lookbook/entities/concerns/navigable.rb
lookbook-1.4.1 lib/lookbook/entities/concerns/navigable.rb