Class: ActiveSupport::CodeGenerator::MethodSet
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/code_generator.rb
Constant Summary collapse
Instance Method Summary collapse
- #apply(owner, path, line) ⇒ Object
- #define_cached_method(name, as: name) ⇒ Object
-
#initialize(namespace) ⇒ MethodSet
constructor
A new instance of MethodSet.
Constructor Details
#initialize(namespace) ⇒ MethodSet
Returns a new instance of MethodSet.
8 9 10 11 12 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/code_generator.rb', line 8 def initialize(namespace) @cache = METHOD_CACHES[namespace] @sources = [] @methods = {} end |
Instance Method Details
#apply(owner, path, line) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/code_generator.rb', line 25 def apply(owner, path, line) unless @sources.empty? @cache.module_eval("# frozen_string_literal: true\n" + @sources.join(";"), path, line) end @methods.each do |name, as| owner.define_method(name, @cache.instance_method(as)) end end |
#define_cached_method(name, as: name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/code_generator.rb', line 14 def define_cached_method(name, as: name) name = name.to_sym as = as.to_sym @methods.fetch(name) do unless @cache.method_defined?(as) yield @sources end @methods[name] = as end end |