Sha256: 1a2121e77e54a7d054d4da39f0c315b8d24fe66f513382b932ad31b4bba4b692

Contents?: true

Size: 803 Bytes

Versions: 1

Compression:

Stored size: 803 Bytes

Contents

# encoding: UTF-8

module Bunto
  module Drops
    class DocumentDrop < Drop
      extend Forwardable

      mutable false

      def_delegator :@obj, :next_doc, :next
      def_delegator :@obj, :previous_doc, :previous
      def_delegator :@obj, :relative_path, :path
      def_delegators :@obj, :id, :output, :content, :to_s, :relative_path, :url

      def collection
        @obj.collection.label
      end

      def excerpt
        fallback_data['excerpt'].to_s
      end

      def <=>(other)
        return nil unless other.is_a? DocumentDrop
        cmp = self['date'] <=> other['date']
        cmp = self['path'] <=> other['path'] if cmp.nil? || cmp == 0
        cmp
      end

      private
      def_delegator :@obj, :data, :fallback_data
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bunto-3.0.0 lib/bunto/drops/document_drop.rb