Class: Pulitzer::CreatePostTag

Inherits:
Object
  • Object
show all
Defined in:
app/interactions/pulitzer/create_post_tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#postObject

Returns the value of attribute post.



2
3
4
# File 'app/interactions/pulitzer/create_post_tag.rb', line 2

def post
  @post
end

#request_paramsObject

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

#callObject



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 
end

#post_tag_paramsObject



18
19
20
# File 'app/interactions/pulitzer/create_post_tag.rb', line 18

def 
  request_params[:post_tag].permit!
end