Sha256: 1925a19cfa83781e98ce3d83d7863625a62cc91eb15d5c366e82bc3b9b174549

Contents?: true

Size: 1.67 KB

Versions: 7

Compression:

Stored size: 1.67 KB

Contents

require_relative 'resource_requester'

module Contentful
  module Management
    # Wrapper for Entry manipulation for a specific Content Type
    # @private
    class ContentTypeEntryMethodsFactory
      attr_reader :content_type

      # @private
      def initialize(content_type)
        @content_type = content_type
      end

      # Gets all entries for a specific ContentType
      #
      # @param [Hash] params
      # @see _ For complete option list: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters
      # @option params [String] 'sys.id'
      # @option params [String] :limit
      # @option params [String] :skip
      # @option params [String] :order
      #
      # @return [Contentful::Management::Array<Contentful::Management::Entry>]
      def all(params = {})
        Entry.all(content_type.client, content_type.space.id, params.merge(content_type: content_type.id))
      end

      # Creates an entry for a content type.
      #
      # @param [Hash] attributes
      #
      # @return [Contentful::Management::Entry]
      def create(attributes)
        attributes[:content_type] = content_type
        Entry.create(content_type.client, content_type.space.id, attributes)
      end

      # Instantiates an empty entry for a content type.
      #
      # @return [Contentful::Management::Entry]
      def new
        dynamic_entry_class = content_type.client.register_dynamic_entry(
          content_type.id,
          DynamicEntry.create(content_type, content_type.client)
        )
        dynamic_entry = dynamic_entry_class.new
        dynamic_entry.content_type = content_type
        dynamic_entry
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contentful-management-1.10.1 lib/contentful/management/content_type_entry_methods_factory.rb
contentful-management-1.10.0 lib/contentful/management/content_type_entry_methods_factory.rb
contentful-management-1.9.0 lib/contentful/management/content_type_entry_methods_factory.rb
contentful-management-1.8.1 lib/contentful/management/content_type_entry_methods_factory.rb
contentful-management-1.8.0 lib/contentful/management/content_type_entry_methods_factory.rb
contentful-management-1.7.0 lib/contentful/management/content_type_entry_methods_factory.rb
contentful-management-1.6.0 lib/contentful/management/content_type_entry_methods_factory.rb