Module: RactorRailsShim::Patches::ActiveModelAttribute

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

Class Method Summary collapse

Class Method Details

.installObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/ractor_rails_shim/patches/active_model_attribute.rb', line 134

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)


162
163
164
# File 'lib/ractor_rails_shim/patches/active_model_attribute.rb', line 162

def self.installed?
  @installed
end

.reset_installed_for_test!Object



166
167
168
# File 'lib/ractor_rails_shim/patches/active_model_attribute.rb', line 166

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