Class: Contentful::Management::ContentTypeEntryMethodsFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful/management/content_type_entry_methods_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_type) ⇒ ContentTypeEntryMethodsFactory

Returns a new instance of ContentTypeEntryMethodsFactory.



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

def initialize(content_type)
  @content_type = content_type
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



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

def content_type
  @content_type
end

Instance Method Details

#all(params = {}) ⇒ Object



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

def all(params = {})
  Entry.all(content_type.space.id, params.merge(content_type: content_type.id))
end

#create(attributes) ⇒ Object



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

def create(attributes)
  Entry.create(content_type, attributes)
end

#newObject



18
19
20
21
22
23
# File 'lib/contentful/management/content_type_entry_methods_factory.rb', line 18

def new
  dynamic_entry_class = content_type.client.register_dynamic_entry(content_type.id, DynamicEntry.create(content_type))
  dynamic_entry = dynamic_entry_class.new
  dynamic_entry.content_type = content_type
  dynamic_entry
end