Sha256: 7f49ea2092c90867d02f3dc2218072e0597aab63868a15663ebe365e818108e3

Contents?: true

Size: 609 Bytes

Versions: 8

Compression:

Stored size: 609 Bytes

Contents

module SearchKit
  module Models
    class Documents
      include Enumerable

      def self.[](*arguments)
        new(arguments)
      end

      attr_reader :contents, :member_class

      def initialize(contents = [])
        @contents     = contents
        @member_class = SearchKit::Models::Document
      end

      def <<(new_doc)
        case new_doc
        when Hash         then contents << member_class.new(new_doc)
        when member_class then contents << new_doc
        else contents
        end
      end

      def each(&block)
        contents.each(&block)
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
search-kit-0.0.10 lib/search_kit/models/documents.rb
search-kit-0.0.9 lib/search_kit/models/documents.rb
search-kit-0.0.8 lib/search_kit/models/documents.rb
search-kit-0.0.7 lib/search_kit/models/documents.rb
search-kit-0.0.6 lib/search_kit/models/documents.rb
search-kit-0.0.5 lib/search_kit/models/documents.rb
search-kit-0.0.4 lib/search_kit/models/documents.rb
search-kit-0.0.3 lib/search_kit/models/documents.rb