Sha256: 1a6ee2dae1c2e02e9e364cbee71ef14359f3002558d54a89b8773d2718107412

Contents?: true

Size: 519 Bytes

Versions: 15

Compression:

Stored size: 519 Bytes

Contents

module Blogo
  class CreatePostService < BasePostService
    attr_reader :post

    def initialize(user, params)
      @post        = user.posts.build
      @tags_string = params.delete(:tags_string)
      @post_attrs  = params
    end

    def create!
      assign_attributes
      return false unless @post.valid?

      @post.transaction do
        @post.save!
        set_tags!(@tags_string)

        # Save tags_string
        # TODO: fix to have 1 save
        @post.save!
      end

      true
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blogo-0.1.4 app/services/blogo/create_post_service.rb
blogo-0.1.3 app/services/blogo/create_post_service.rb
blogo-0.1.2 app/services/blogo/create_post_service.rb
blogo-0.1.1 app/services/blogo/create_post_service.rb
blogo-0.1.0 app/services/blogo/create_post_service.rb
blogo-0.0.10 app/services/blogo/create_post_service.rb
blogo-0.0.9 app/services/blogo/create_post_service.rb
blogo-0.0.8 app/services/blogo/create_post_service.rb
blogo-0.0.7 app/services/blogo/create_post_service.rb
blogo-0.0.6 app/services/blogo/create_post_service.rb
blogo-0.0.5 app/services/blogo/create_post_service.rb
blogo-0.0.4 app/services/blogo/create_post_service.rb
blogo-0.0.3 app/services/blogo/create_post_service.rb
blogo-0.0.2 app/services/blogo/create_post_service.rb
blogo-0.0.1 app/services/blogo/create_post_service.rb