Sha256: e9086bdfc9ce0f7652b613a147c850b1de836b47b37231b37a0edc022b929487

Contents?: true

Size: 538 Bytes

Versions: 12

Compression:

Stored size: 538 Bytes

Contents

class Pulitzer::CreatePostTag
  attr_accessor :post, :request_params

  def initialize(post, params)
    self.post           = post
    self.request_params = params
  end

  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.post_tags.create post_tag_params
  end

  def post_tag_params
    request_params[:post_tag].permit!
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pulitzer-0.2.2 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.2.1 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.2.0 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.10 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.9 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.8 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.7 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.6 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.5 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.4 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.3 app/interactions/pulitzer/create_post_tag.rb
pulitzer-0.1.2 app/interactions/pulitzer/create_post_tag.rb