Class: Blogo::CreatePostService
- Inherits:
-
BasePostService
- Object
- BasePostService
- Blogo::CreatePostService
- Defined in:
- app/services/blogo/create_post_service.rb
Constant Summary
Constants inherited from BasePostService
Instance Attribute Summary collapse
-
#post ⇒ Object
readonly
Returns the value of attribute post.
Instance Method Summary collapse
- #create! ⇒ Object
-
#initialize(user, params) ⇒ CreatePostService
constructor
A new instance of CreatePostService.
Constructor Details
#initialize(user, params) ⇒ CreatePostService
Returns a new instance of CreatePostService.
5 6 7 8 9 |
# File 'app/services/blogo/create_post_service.rb', line 5 def initialize(user, params) @post = user.posts.build @tags_string = params.delete(:tags_string) @post_attrs = params end |
Instance Attribute Details
#post ⇒ Object (readonly)
Returns the value of attribute post.
3 4 5 |
# File 'app/services/blogo/create_post_service.rb', line 3 def post @post end |
Instance Method Details
#create! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/blogo/create_post_service.rb', line 11 def create! assign_attributes return false unless @post.valid? @post.transaction do @post.save! (@tags_string) # Save tags_string # TODO: fix to have 1 save @post.save! end true end |