Class: Unparser::Adamantium::MethodBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/unparser/adamantium/method_builder.rb

Overview

Build the memoized method

Defined Under Namespace

Classes: BlockNotAllowedError, InvalidArityError

Instance Method Summary collapse

Constructor Details

#initialize(descendant, method_name) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize an object to build a memoized method

Parameters:

  • descendant (Module)
  • method_name (Symbol)


47
48
49
50
51
52
53
# File 'lib/unparser/adamantium/method_builder.rb', line 47

def initialize(descendant, method_name)
  @descendant          = descendant
  @method_name         = method_name
  @original_visibility = visibility
  @original_method     = @descendant.instance_method(@method_name)
  assert_arity(@original_method.arity)
end

Instance Method Details

#callUnboundMethod

Build a new memoized method

Examples:

method_builder.call  # => creates new method

Returns:

  • (UnboundMethod)


63
64
65
66
67
68
# File 'lib/unparser/adamantium/method_builder.rb', line 63

def call
  remove_original_method
  create_memoized_method
  set_method_visibility
  @original_method
end