Sha256: 0d3d03b6c046a5e99ecef873bfb864f52fc78a180c4b1eb9769464b55c56cfd3

Contents?: true

Size: 992 Bytes

Versions: 33

Compression:

Stored size: 992 Bytes

Contents

require_relative 'resource_requester'

module Contentful
  module Management
    # Wrapper for Space Association Methods
    # @private
    module SpaceAssociationMethodsFactory
      attr_reader :space

      def initialize(space)
        @space = space
      end

      def all(params = {})
        associated_class.all(space.client, space.id, nil, params)
      end

      def find(id)
        associated_class.find(space.client, space.id, id)
      end

      def create(attributes)
        associated_class.create(space.client, space.id, attributes)
      end

      def new
        object = associated_class.new
        object.sys[:space] = space
        object.client = space.client
        object
      end

      def associated_class
        class_name = /\A(.+)Space(.+)MethodsFactory\z/.match(self.class.name).captures.join
        class_name.split('::').reduce(Object) do |mod, actual_class_name|
          mod.const_get(actual_class_name)
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
contentful-management-3.8.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.7.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.6.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.5.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.4.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.3.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.2.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.1.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-3.0.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.13.1 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.13.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.12.1 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.12.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.11.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.10.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.9.1 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.9.0 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.8.2 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.8.1 lib/contentful/management/space_association_methods_factory.rb
contentful-management-2.8.0 lib/contentful/management/space_association_methods_factory.rb