Sha256: 4b2e2f1257263bf6e9c8fb758e816abfd11f9cb3eceed570fd38dd40e19be804

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

module ObjectAttorney
  module Errors
    NoDefendantToDefendError = Class.new(StandardError)

    # ActiveModel::Errors told me to declare
    # the following methods for a minimal implementation
    module ClassMethods
      def human_attribute_name(attribute, _ = {})
        attribute
      end

      # Necessary for proper translations
      def lookup_ancestors
        [self]
      end

      # Necessary for proper translations
      def i18n_scope
        :activemodel
      end
    end

    def self.included(base_class)
      base_class.extend ActiveModel::Naming
      base_class.extend ClassMethods
    end

    def errors
      @errors ||= ActiveModel::Errors.new(self)
    end

    def read_attribute_for_validation(attribute)
      send(attribute)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
object_attorney-3.1.1 lib/object_attorney/errors.rb
object_attorney-3.1.0 lib/object_attorney/errors.rb
object_attorney-3.0.7 lib/object_attorney/errors.rb