-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from contentful/modifying_nil_bugfix
Modifying nil bugfix
- Loading branch information
Showing
10 changed files
with
158 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
lib/contentful/management/content_type_entry_methods_factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Contentful | ||
module Management | ||
class ContentTypeEntryMethodsFactory | ||
|
||
attr_reader :content_type | ||
|
||
def initialize(content_type) | ||
@content_type = content_type | ||
end | ||
|
||
def all(params = {}) | ||
Entry.all(content_type.space.id, params.merge(content_type: content_type.id)) | ||
end | ||
|
||
def create(attributes) | ||
Entry.create(content_type, attributes) | ||
end | ||
|
||
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 | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require_relative 'space_association_methods_factory' | ||
|
||
module Contentful | ||
module Management | ||
class SpaceAssetMethodsFactory | ||
|
||
include Contentful::Management::SpaceAssociationMethodsFactory | ||
|
||
end | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
lib/contentful/management/space_association_methods_factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Contentful | ||
module Management | ||
module SpaceAssociationMethodsFactory | ||
|
||
attr_reader :space | ||
|
||
def initialize(space) | ||
@space = space | ||
end | ||
|
||
def all(params = {}) | ||
associated_class.all(space.id, params) | ||
end | ||
|
||
def find(id) | ||
associated_class.find(space.id, id) | ||
end | ||
|
||
def create(attributes) | ||
associated_class.create(space.id, attributes) | ||
end | ||
|
||
def new | ||
object = associated_class.new | ||
object.sys[:space] = space | ||
object | ||
end | ||
|
||
def associated_class | ||
class_name = /\A(.+)Space(.+)MethodsFactory\z/.match(self.class.name).captures.join | ||
class_name.split('::').inject(Object) do |mod, class_name| | ||
mod.const_get(class_name) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
lib/contentful/management/space_content_type_methods_factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require_relative 'space_association_methods_factory' | ||
|
||
module Contentful | ||
module Management | ||
class SpaceContentTypeMethodsFactory | ||
|
||
include Contentful::Management::SpaceAssociationMethodsFactory | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require_relative 'space_association_methods_factory' | ||
|
||
module Contentful | ||
module Management | ||
class SpaceEntryMethodsFactory | ||
|
||
include Contentful::Management::SpaceAssociationMethodsFactory | ||
|
||
def create(attributes) | ||
fail 'Not supported' | ||
end | ||
|
||
def new | ||
fail 'Not supported' | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require_relative 'space_association_methods_factory' | ||
|
||
module Contentful | ||
module Management | ||
class SpaceLocaleMethodsFactory | ||
|
||
include Contentful::Management::SpaceAssociationMethodsFactory | ||
|
||
def new | ||
fail 'Not supported' | ||
end | ||
|
||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
lib/contentful/management/space_webhook_methods_factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require_relative 'space_association_methods_factory' | ||
|
||
module Contentful | ||
module Management | ||
class SpaceWebhookMethodsFactory | ||
|
||
include Contentful::Management::SpaceAssociationMethodsFactory | ||
|
||
def create(attributes) | ||
fail 'Not supported' | ||
end | ||
|
||
def new | ||
fail 'Not supported' | ||
end | ||
|
||
end | ||
end | ||
end |