Sha256: 9772f753ef99f5dad501fc5fc9159dc521d655eebabf05510e5afd6a22c55108

Contents?: true

Size: 726 Bytes

Versions: 4

Compression:

Stored size: 726 Bytes

Contents

module ObjectAttorney
  module Errors
    # 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

4 entries across 4 versions & 1 rubygems

Version Path
object_attorney-3.0.6 lib/object_attorney/errors.rb
object_attorney-3.0.5 lib/object_attorney/errors.rb
object_attorney-3.0.4 lib/object_attorney/errors.rb
object_attorney-3.0.3 lib/object_attorney/errors.rb