Module: RactorRailsShim::FallbackBuilder::ValueLookup::Ivar

Defined in:
lib/ractor_rails_shim/roles/fallback_builder.rb

Overview

read @<attr_name> in main.

Class Method Summary collapse

Class Method Details

.lookup(owner_name, attr_name, _ies_key, safe_const_get:) ⇒ Object



164
165
166
167
168
169
170
171
# File 'lib/ractor_rails_shim/roles/fallback_builder.rb', line 164

def self.lookup(owner_name, attr_name, _ies_key, safe_const_get:, **)
  return nil unless owner_name && attr_name.is_a?(Symbol)
  owner_mod = safe_const_get.call(owner_name)
  return nil unless owner_mod && owner_mod.instance_variable_defined?("@#{attr_name}")
  owner_mod.instance_variable_get("@#{attr_name}")
rescue StandardError
  nil
end