Class: Pulitzer::PartialTagsController::CreatePartialTag

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

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ CreatePartialTag

Returns a new instance of CreatePartialTag.



3
4
5
# File 'app/interactions/pulitzer/partial_tags_controller/create_partial_tag.rb', line 3

def initialize(params)
  @request_params = params
end

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
# File 'app/interactions/pulitzer/partial_tags_controller/create_partial_tag.rb', line 7

def call
  label_id = partial_tag_params[:label_id]
  unless (Integer(label_id) rescue false)
    tag = Pulitzer::Tag.where(name: label_id).first_or_create
    @request_params[:partial_tag][:label_id] = tag.id
  end
  Pulitzer::PartialTag.create partial_tag_params
end

#partial_tag_paramsObject



16
17
18
# File 'app/interactions/pulitzer/partial_tags_controller/create_partial_tag.rb', line 16

def partial_tag_params
  @request_params[:partial_tag].permit!
end