Sha256: be73477616ad192045b1fb47daf55c51b92d170d7a7991fd981a1675c8901735

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

module CsvRowModel
  module Import
    class File
      module Validations
        extend ActiveSupport::Concern

        include ActiveModel::Validations
        include Validators::ValidateAttributes

        included do
          validate_attributes :csv
        end

        # @return [Boolean] returns true, if the file should abort reading
        def abort?
          !valid? || !!current_row_model.try(:abort?)
        end

        # @return [Boolean] returns true, if the file should skip `current_row_model`
        def skip?
          !!current_row_model.try(:skip?)
        end

        protected
        def _abort?
          abort = abort?
          run_callbacks(:abort) if abort
          abort
        end

        def _skip?
          skip = skip?
          run_callbacks(:skip) if skip
          skip
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
csv_row_model-0.4.1 lib/csv_row_model/import/file/validations.rb
csv_row_model-0.4.0 lib/csv_row_model/import/file/validations.rb