Module: ConvenientService::Common::Plugins::HasAttributes::UsingActiveModelAttributes::Patches Private

Defined in:
lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/patches/active_model_attributes.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

TODO: Remove this patch when Rails updates def initialize(*) to def initialize(*args, **kwargs, &block). https://github.com/rails/rails/blob/3872bc0e54d32e8bf3a6299b0bfe173d94b072fc/activemodel/lib/active_model/attributes.rb#L78

Since:

  • 1.0.0

Constant Summary collapse

ActiveModelAttributes =

Since:

  • 1.0.0

::ActiveModel::Attributes.dup.tap do |mod|
  mod.module_eval do
    ##
    # NOTE: Overrides `initialize` since current Rails implementation can not accept kwargs.
    #
    # TODO: Open a PR to Rails.
    #
    def initialize(*args, **kwargs, &block)
      ##
      # IMPORTANT: Should be kept in sync with:
      # https://github.com/rails/rails/blob/3872bc0e54d32e8bf3a6299b0bfe173d94b072fc/activemodel/lib/active_model/attributes.rb#L78
      #
      @attributes = self.class._default_attributes.deep_dup
      super
    end
  end
end