Sha256: a33a068c1b502d6053badc90660c4727090cbc2ae038c360becc5b67687da31f

Contents?: true

Size: 995 Bytes

Versions: 62

Compression:

Stored size: 995 Bytes

Contents

module Workarea
  module DataFile
    class Export
      include ApplicationDocument
      include Operation

      field :query_id, type: String, default: AdminSearchQueryWrapper.new.to_global_id
      field :ids, type: Array, default: []
      field :exclude_ids, type: Array, default: []
      field :emails, type: Array, default: []
      list_field :emails

      validate :emails_are_valid

      def process!
        set(started_at: Time.current)
        run_callbacks(:process) { format.export! }
        update_attributes!(file: tempfile.tap(&:close), completed_at: Time.current)
      end

      def models
        @models ||= AdminQueryOperation.new(attributes)
      end

      private

      def emails_are_valid
        return unless emails.present?

        validator = EmailValidator.new(attributes: attributes)
        emails.each do |email|
          validator.validate_each(self, :emails, email)
          break if errors[:emails].any?
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/data_file/export.rb
workarea-core-3.5.26 app/models/workarea/data_file/export.rb
workarea-core-3.4.45 app/models/workarea/data_file/export.rb
workarea-core-3.5.25 app/models/workarea/data_file/export.rb
workarea-core-3.5.23 app/models/workarea/data_file/export.rb
workarea-core-3.4.44 app/models/workarea/data_file/export.rb
workarea-core-3.5.22 app/models/workarea/data_file/export.rb
workarea-core-3.4.43 app/models/workarea/data_file/export.rb
workarea-core-3.5.21 app/models/workarea/data_file/export.rb
workarea-core-3.4.42 app/models/workarea/data_file/export.rb
workarea-core-3.5.20 app/models/workarea/data_file/export.rb
workarea-core-3.4.41 app/models/workarea/data_file/export.rb
workarea-core-3.5.19 app/models/workarea/data_file/export.rb
workarea-core-3.4.40 app/models/workarea/data_file/export.rb
workarea-core-3.5.18 app/models/workarea/data_file/export.rb
workarea-core-3.4.39 app/models/workarea/data_file/export.rb
workarea-core-3.5.17 app/models/workarea/data_file/export.rb
workarea-core-3.4.38 app/models/workarea/data_file/export.rb
workarea-core-3.5.16 app/models/workarea/data_file/export.rb
workarea-core-3.4.37 app/models/workarea/data_file/export.rb