Module: Contentful::Management::SpaceAssociationMethodsFactory

Included in:
SpaceAssetMethodsFactory, SpaceContentTypeMethodsFactory, SpaceEntryMethodsFactory, SpaceLocaleMethodsFactory, SpaceWebhookMethodsFactory
Defined in:
lib/contentful/management/space_association_methods_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#spaceObject (readonly)

Returns the value of attribute space.



4
5
6
# File 'lib/contentful/management/space_association_methods_factory.rb', line 4

def space
  @space
end

Instance Method Details

#all(params = {}) ⇒ Object



10
11
12
# File 'lib/contentful/management/space_association_methods_factory.rb', line 10

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

#associated_classObject



28
29
30
31
32
33
# File 'lib/contentful/management/space_association_methods_factory.rb', line 28

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

#create(attributes) ⇒ Object



18
19
20
# File 'lib/contentful/management/space_association_methods_factory.rb', line 18

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

#find(id) ⇒ Object



14
15
16
# File 'lib/contentful/management/space_association_methods_factory.rb', line 14

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

#initialize(space) ⇒ Object



6
7
8
# File 'lib/contentful/management/space_association_methods_factory.rb', line 6

def initialize(space)
  @space = space
end

#newObject



22
23
24
25
26
# File 'lib/contentful/management/space_association_methods_factory.rb', line 22

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