Class: Ractor::Cache::Strategy::Prebuild
- Inherits:
-
Base
- Object
- Base
- Ractor::Cache::Strategy::Prebuild
show all
- Defined in:
- lib/ractor/cache/strategy.rb
Instance Attribute Summary
Attributes inherited from Base
#method_name, #parameters
Instance Method Summary
collapse
Methods inherited from Base
#compile_store_init
Constructor Details
Returns a new instance of Prebuild.
57
58
59
60
|
# File 'lib/ractor/cache/strategy.rb', line 57
def initialize(*)
super
raise ArgumentError, "Can not cache method #{method_name} by prebuilding because it accepts arguments" if @has_arguments
end
|
Instance Method Details
#compile_accessor ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/ractor/cache/strategy.rb', line 66
def compile_accessor
<<~RUBY
def #{method_name}(#{signature})
r = ractor_cache.#{method_name}
return r unless r == EMPTY_CACHE
ractor_cache.#{method_name} = super
end
RUBY
end
|
#deep_freeze_callback(instance) ⇒ Object
62
63
64
|
# File 'lib/ractor/cache/strategy.rb', line 62
def deep_freeze_callback(instance)
instance.__send__ method_name
end
|