Module: RactorRailsShim::Patches::ActiveModelAttribute

Defined in:
lib/ractor_rails_shim/patches/active_model_attribute.rb

Class Method Summary collapse

Class Method Details

.installObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/ractor_rails_shim/patches/active_model_attribute.rb', line 197

def self.install
  @mutex.synchronize do
    return true if @installed
    @installed = true
    next unless defined?(::ActiveModel::Attribute)
    ::ActiveModel::Attribute.include(::RactorRailsShim::ActiveModelAttributePatch)
    if defined?(::ActiveModel::AttributeRegistration) &&
       ::ActiveModel::AttributeRegistration.const_defined?(:ClassMethods)
      ::ActiveModel::AttributeRegistration::ClassMethods.prepend(
        ::RactorRailsShim::ActiveModelAttributeRegistrationPatch
      )
    end
    if defined?(::ActiveRecord::Attributes) &&
       ::ActiveRecord::Attributes.const_defined?(:ClassMethods)
      ::ActiveRecord::Attributes::ClassMethods.prepend(
        ::RactorRailsShim::ActiveRecordAttributesPatch
      )
    end
    if defined?(::ActiveRecord::ModelSchema) &&
       ::ActiveRecord::ModelSchema.const_defined?(:ClassMethods)
      ::ActiveRecord::ModelSchema::ClassMethods.prepend(
        ::RactorRailsShim::ActiveRecordModelSchemaPatch
      )
    end
  end
  true
end

.installed?Boolean

Returns:

  • (Boolean)


225
226
227
# File 'lib/ractor_rails_shim/patches/active_model_attribute.rb', line 225

def self.installed?
  @installed
end

.reset_installed_for_test!Object



229
230
231
# File 'lib/ractor_rails_shim/patches/active_model_attribute.rb', line 229

def self.reset_installed_for_test!
  @mutex.synchronize { @installed = false }
end