Sha256: 6aeaa252037c237c6477139b66f4624f85c9dae07c8c66ad62360c483aa8d0e9

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 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, _options = {})
        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

2 entries across 2 versions & 1 rubygems

Version Path
object_attorney-3.2.0 lib/object_attorney/errors.rb
object_attorney-3.1.2 lib/object_attorney/errors.rb