123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::CodeGenerator

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: activesupport/lib/active_support/code_generator.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(owner, path, line) ⇒ CodeGenerator

[ GitHub ]

  
# File 'activesupport/lib/active_support/code_generator.rb', line 48

def initialize(owner, path, line)
  @owner = owner
  @path = path
  @line = line
  @namespaces = Hash.new { |h, k| h[k] = MethodSet.new(k) }
end

Class Method Details

.batch(owner, path, line)

[ GitHub ]

  
# File 'activesupport/lib/active_support/code_generator.rb', line 36

def batch(owner, path, line)
  if owner.is_a?(CodeGenerator)
    yield owner
  else
    instance = new(owner, path, line)
    result = yield instance
    instance.execute
    result
  end
end

Instance Method Details

#define_cached_method(name, namespace:, as: name, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/code_generator.rb', line 55

def define_cached_method(name, namespace:, as: name, &block)
  @namespaces[namespace].define_cached_method(name, as: as, &block)
end

#execute

[ GitHub ]

  
# File 'activesupport/lib/active_support/code_generator.rb', line 59

def execute
  @namespaces.each_value do |method_set|
    method_set.apply(@owner, @path, @line - 1)
  end
end