Class: RubyNext::Core::Patches
- Inherits:
-
Object
- Object
- RubyNext::Core::Patches
- Defined in:
- lib/ruby-next/core.rb
Overview
Registry for patches
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#refined ⇒ Object
readonly
Returns the value of attribute refined.
Instance Method Summary collapse
-
#<<(patch) ⇒ Object
Register new patch.
-
#initialize ⇒ Patches
constructor
A new instance of Patches.
Constructor Details
#initialize ⇒ Patches
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
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
87 88 89 |
# File 'lib/ruby-next/core.rb', line 87 def extensions @extensions end |
#refined ⇒ Object (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
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 |