Sha256: c829eed586c7742a067b8b8616c8bd9eb8290476b3900db1bdd0927c5e6fd623

Contents?: true

Size: 812 Bytes

Versions: 10

Compression:

Stored size: 812 Bytes

Contents

module Arpa
  module Services
    module Profiles
      module Create
        class ProfileCreator

          def create(params)
            profile = profile_instance(params)
            validate_profile(profile)
            creator_repo.create(profile)
          end

          private

          def profile_instance(params)
            Arpa::Entities::Profile.new(params)
          end

          def validate_profile(profile)
            validator = Arpa::Validators::ProfileValidator.new(profile)
            raise Arpa::Exceptions::RecordInvalid.new(message: validator.errors.messages, errors: validator.errors) unless validator.valid?
          end

          def creator_repo
            @creator_repo ||= Arpa::Repositories::Profiles::Creator.new
          end

        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
arpa-0.2.0 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.1.0 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.9 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.8 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.7 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.6 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.5 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.4 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.3 lib/arpa/services/profiles/create/profile_creator.rb
arpa-0.0.2 lib/arpa/services/profiles/create/profile_creator.rb