Sha256: 94d28400f871cee61e0f5b148d2f8e190e0a618a171aad0ae423ac148ead72dc

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

class ProjectCreator
  attr_reader :user
  attr_reader :project

  def initialize(user, name = nil, location = nil, description = nil)
    @user = user
    @project = Project.new(
      name: name,
      location: location,
      description: description
    )
  end

  def create
    ActiveRecord::Base.transaction do
      if project.save
        ProjectUser.create(user: user, project: project, role: "owner")
        AreaSeeder.seed(project)
        CategorySeeder.seed(project)
      end
    end

    project
  end

  def self.create(user, name = nil, location = nil, description = nil)
    new(user,
      name,
      location,
      description
    ).create
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
self_systeem-0.1.0 test/dummy_app/app/services/project_creator.rb