Class: RubyNext::Core::Patches

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-next/core.rb

Overview

Registry for patches

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePatches

Returns a new instance of Patches.



89
90
91
92
93
# File 'lib/ruby-next/core.rb', line 89

def initialize
  @names = Set.new
  @extensions = Hash.new { |h, k| h[k] = [] }
  @refined = Hash.new { |h, k| h[k] = [] }
end

Instance Attribute Details

#extensionsObject (readonly)

Returns the value of attribute extensions.



87
88
89
# File 'lib/ruby-next/core.rb', line 87

def extensions
  @extensions
end

#refinedObject (readonly)

Returns the value of attribute refined.



87
88
89
# File 'lib/ruby-next/core.rb', line 87

def refined
  @refined
end

Instance Method Details

#<<(patch) ⇒ Object

Register new patch

Raises:

  • (ArgumentError)


96
97
98
99
100
101
# File 'lib/ruby-next/core.rb', line 96

def <<(patch)
  raise ArgumentError, "Patch already registered: #{patch.name}" if @names.include?(patch.name)
  @names << patch.name
  @extensions[patch.mod] << patch if patch.core_ext?
  patch.refineables.each { |r| @refined[r] << patch } unless patch.native?
end