README.md in polyfill-0.7.0 vs README.md in polyfill-0.8.0

- old
+ new

@@ -31,11 +31,11 @@ ## Installation Add it to your Gemfile: ```ruby -gem 'polyfill', '0.7.0' +gem 'polyfill', '0.8.0' ``` Or install it manually: ```sh @@ -50,10 +50,12 @@ 2. Features should not significantly burden the runtime. 3. Keep everything modular so users can be specific or broad in their usage. ## Usage +### Polyfill + With the `Polyfill` method, you can polyfill methods for one or more Ruby objects. Each object is passed as a key. The value is an array of strings containing the methods you would like to polyfill. Instance methods need to start with '#' and class methods need to start with '.'. @@ -86,22 +88,44 @@ ```ruby using Polyfill(native: true, Numeric: :all) ``` +### Polyfill.get + Prior to Ruby 2.4, refinements do not work on Modules. When using a polyfill on a module it will instead refine the core classes that use the module. If you're building your own class, it will not receive the polyfill. Instead, -you can add the polyfill by using `include`. +you can `include` (or `extend`) in a polyfill with `Polyfill.get`. ```ruby class Foo include Comparable - include Polyfill(Comparable: :all) + include Polyfill.get(:Comparable, :all) end ``` +To use specific methods you can pass an array of symbols in place of `:all`. + +```ruby +class Foo + include Comparable + include Polyfill.get(:Comparable, %i[clamp]) +end +``` + +Like before, the polyfills can be halted at a maximum version with the +`:version` option. The version must be a string with the major and minor +version only. + +```ruby +class Foo + include Comparable + include Polyfill.get(:Comparable, :all, version: '2.3') +end +``` + ## Implementation Table ### 2.4 | Object | Method | Implemented | Notes | @@ -109,11 +133,11 @@ | Array | #concat | Yes | | | #max | No | This method already existed but was inherited from `Enumerable`. It was optimized on `Array` so redefining `Enumerable#max` no longer affects this. | | #min | No | This method already existed but was inherited from `Enumerable`. It was optimized on `Array` so redefining `Enumerable#min` no longer affects this. | | #pack | No | | | #sum | Yes | -| BasicObject | #__send__ | No | +| BasicObject | #\_\_send\_\_ | No | | Binding | #irb | No | | Comparable | #clamp | Yes | | CSV | #new | No | | Dir | .empty? | Yes | | Enumerable | #chunk | Yes | @@ -295,21 +319,20 @@ | Enumerable | #max | No | | | #max_by | No | | | #min | No | | | #min_by | No | | | #slice_after | Yes | -| | #slice_when | No | +| | #slice_when | Yes | | Etc | .confstr | No | | | .sysconf | No | | | .nprocessors | No | | | .uname | No | | Float | #next_float | No | | | #prev_float | No | | File | .birthtime | No | | | #birthtime | No | -| | .find | No | -| | #find | No | | File::Stat | #birthtime | No | +| Find | .find | No | | GC | .latest_gc_info | No | | | .stat | No | | IO | #each_codepoint | No | | | #nonblock_read | No | | | #nonblock_write | No |