Class: Pulitzer::PostTypesController::CreateSingletonPost
- Inherits:
-
Object
- Object
- Pulitzer::PostTypesController::CreateSingletonPost
- Defined in:
- app/interactions/pulitzer/post_types_controller/create_singleton_post.rb
Instance Attribute Summary collapse
-
#post_type_version ⇒ Object
Returns the value of attribute post_type_version.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(post_type_version) ⇒ CreateSingletonPost
constructor
A new instance of CreateSingletonPost.
Constructor Details
#initialize(post_type_version) ⇒ CreateSingletonPost
Returns a new instance of CreateSingletonPost.
4 5 6 7 |
# File 'app/interactions/pulitzer/post_types_controller/create_singleton_post.rb', line 4 def initialize(post_type_version) self.post_type_version = post_type_version self.title = post_type_version.name end |
Instance Attribute Details
#post_type_version ⇒ Object
Returns the value of attribute post_type_version.
2 3 4 |
# File 'app/interactions/pulitzer/post_types_controller/create_singleton_post.rb', line 2 def post_type_version @post_type_version end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'app/interactions/pulitzer/post_types_controller/create_singleton_post.rb', line 2 def title @title end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 |
# File 'app/interactions/pulitzer/post_types_controller/create_singleton_post.rb', line 9 def call if post_type_version.singular? && !post_type_version.posts.any? singleton_post = post_type_version.posts.create(title: title) Pulitzer::CreatePostContentElements.new(singleton_post).call end end |