Sha256: 2d9c0ff314d7f272dee3463115cc14e8e2773bc3eb74943170be0cc48bc8b505

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

module Contentful
  module Management
    module Resource
      # Wrapper for Resources with /published API
      module Publisher
        # Publishes a resource.
        #
        # @return [Contentful::Management::Resource]
        def publish
          ResourceRequester.new(client, self.class).publish(
            self,
            {
              space_id: space.id,
              environment_id: environment_id,
              resource_id: id,
              suffix: '/published'
            },
            version: sys[:version]
          )
        end

        # Unpublishes a resource.
        #
        # @return [Contentful::Management::Resource]
        def unpublish
          ResourceRequester.new(client, self.class).unpublish(
            self,
            {
              space_id: space.id,
              environment_id: environment_id,
              resource_id: id,
              suffix: '/published'
            },
            version: sys[:version]
          )
        end

        # Checks if a resource is published.
        #
        # @return [Boolean]
        def published?
          sys[:publishedAt] ? true : false
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
contentful-management-2.6.0 lib/contentful/management/resource/publisher.rb
contentful-management-2.5.0 lib/contentful/management/resource/publisher.rb
contentful-management-2.4.0 lib/contentful/management/resource/publisher.rb
contentful-management-2.3.0 lib/contentful/management/resource/publisher.rb
contentful-management-2.2.2 lib/contentful/management/resource/publisher.rb
contentful-management-2.2.1 lib/contentful/management/resource/publisher.rb
contentful-management-2.2.0 lib/contentful/management/resource/publisher.rb
contentful-management-2.1.1 lib/contentful/management/resource/publisher.rb
contentful-management-2.1.0 lib/contentful/management/resource/publisher.rb
contentful-management-2.0.2 lib/contentful/management/resource/publisher.rb
contentful-management-2.0.1 lib/contentful/management/resource/publisher.rb
contentful-management-2.0.0 lib/contentful/management/resource/publisher.rb