Sha256: 80cb31fceeca0b4717235fe2f7655062a3bdc9792b456c3acf50505329c6f197

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module BusinessFlow
  # Provides compatibility for ActiveSupport/Model 4.x through 7.x
  module Compat
    unless Module.instance_methods.include?(:module_parents)
      # ActiveSupport 5 removed #parents in favor of #module_parents.
      class ::Module
        def module_parents
          parents
        end
      end
    end

    unless ActiveModel::Errors.instance_methods.include?(:merge!)
      # ActiveModel 5 added details (which we do not use here) and #merge!
      # :reek:MissingSafeMethod Look it's the API.
      module ::ActiveModel
        # Amend the errors class with a convenience method.
        class Errors
          def merge!(other)
            other.each do |attribute, message|
              self[attribute] << message
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
business_flow-0.19.6 lib/business_flow/compat.rb