Sha256: 1176a373f90611d785eb4d744e46e97e1dc97cefd92b6234d09e6b02c97703eb

Contents?: true

Size: 577 Bytes

Versions: 5

Compression:

Stored size: 577 Bytes

Contents

require_dependency 'flexite/action_service'

module Flexite
  class Entry
    class CreateService < ActionService
      def call
        if @form.invalid?
          return failure
        end

        @record = @form.type.constantize.create do |record|
          record.value = @form.value
          record.parent_id = @form.parent_id
          record.parent_type = @form.parent_type
        end

        success
      end

      private

      def success
        Result.new(flash: { type: :success, message: 'Entry was created!' }, data: @record)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flexite-0.0.7 app/services/flexite/entry/create_service.rb
flexite-0.0.6 app/services/flexite/entry/create_service.rb
flexite-0.0.5 app/services/flexite/entry/create_service.rb
flexite-0.0.4 app/services/flexite/entry/create_service.rb
flexite-0.0.3 app/services/flexite/entry/create_service.rb