Sha256: eb901c6331f117771b50bbfe58c1513daf1e4185d668f21785412d9234370c06

Contents?: true

Size: 670 Bytes

Versions: 6

Compression:

Stored size: 670 Bytes

Contents

require 'sc_core/errors/supply_chain_error_codes'

module ActiveModel

  class ErrorMessage < String

    attr_accessor :code, :message

    def initialize(code , message)
      @code , @message = code , message
      super message
    end

  end

  class Errors

    def add(attribute, message = nil, options = {})
      message ||= :invalid
      code = SupplyChainErrorCodes::ArMapping[message]
      if message.is_a?(Symbol)
        message = generate_message(attribute, message, options.except(*CALLBACKS_OPTIONS))
      elsif message.is_a?(Proc)
        message = message.call
      end
      self[attribute] << ErrorMessage.new(code , message)
    end

  end

end

Version data entries

6 entries across 1 versions & 1 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/sc-core-0.0.210/lib/sc_core/active_record_errors_overrides.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/sc-core-0.0.210/lib/sc_core/active_record_errors_overrides.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/sc-core-0.0.210/lib/sc_core/active_record_errors_overrides.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/sc-core-0.0.210/lib/sc_core/active_record_errors_overrides.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/sc-core-0.0.210/lib/sc_core/active_record_errors_overrides.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/sc-core-0.0.210/lib/sc_core/active_record_errors_overrides.rb