Class: Pulitzer::CreatePostTag
- Inherits:
-
Object
- Object
- Pulitzer::CreatePostTag
- Defined in:
- app/interactions/pulitzer/create_post_tag.rb
Instance Attribute Summary collapse
-
#post ⇒ Object
Returns the value of attribute post.
-
#request_params ⇒ Object
Returns the value of attribute request_params.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(post, params) ⇒ CreatePostTag
constructor
A new instance of CreatePostTag.
- #post_tag_params ⇒ Object
Constructor Details
#initialize(post, params) ⇒ CreatePostTag
Returns a new instance of CreatePostTag.
4 5 6 7 |
# File 'app/interactions/pulitzer/create_post_tag.rb', line 4 def initialize(post, params) self.post = post self.request_params = params end |
Instance Attribute Details
#post ⇒ Object
Returns the value of attribute post.
2 3 4 |
# File 'app/interactions/pulitzer/create_post_tag.rb', line 2 def post @post end |
#request_params ⇒ Object
Returns the value of attribute request_params.
2 3 4 |
# File 'app/interactions/pulitzer/create_post_tag.rb', line 2 def request_params @request_params end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/interactions/pulitzer/create_post_tag.rb', line 9 def call label_id = request_params[:post_tag][:label_id] unless (Integer(label_id) rescue false) tag = Pulitzer::Tag.where(name: label_id).first_or_create request_params[:post_tag][:label_id] = tag.id end post.preview_version..create post_tag_params end |
#post_tag_params ⇒ Object
18 19 20 |
# File 'app/interactions/pulitzer/create_post_tag.rb', line 18 def post_tag_params request_params[:post_tag].permit! end |