lib/polyfill.rb in polyfill-1.8.0 vs lib/polyfill.rb in polyfill-1.9.0
- old
+ new
@@ -1,20 +1,22 @@
-require 'polyfill/version'
-require 'polyfill/internal_utils'
+require_relative 'polyfill/version'
+require_relative 'polyfill/internal_utils'
module Polyfill
module Module; end
def get(module_name, methods, options = {})
if Object.const_get(module_name.to_s, false).is_a?(Class)
raise ArgumentError, "#{module_name} is a class not a module"
end
+ version_option = options.delete(:version)
+
#
# parse options
#
- versions = InternalUtils.polyfill_versions_to_use(options.delete(:version))
+ versions = InternalUtils.polyfill_versions_to_use(version_option)
unless options.empty?
raise ArgumentError, "unknown keyword: #{options.first[0]}"
end
@@ -33,11 +35,11 @@
end
#
# build the module to return
#
- InternalUtils.create_module do |mod|
+ InternalUtils.create_module(module_name, methods, options, version_option) do |mod|
# make sure the methods get added if this module is included
mod.singleton_class.send(:define_method, :included) do |base|
modules.each do |module_to_add|
base.include module_to_add unless module_to_add.instance_methods.empty?
end
@@ -88,11 +90,11 @@
end
#
# build the module to return
#
- Polyfill::InternalUtils.create_module do |mod|
+ Polyfill::InternalUtils.create_module(options) do |mod|
objects.each do |object_name, methods|
#
# find all polyfills for the object across all versions
#
modules_with_updates, instance_modules = Polyfill::InternalUtils.modules_to_use(object_name, versions)
@@ -232,10 +234,10 @@
end
end
end
end
-require 'polyfill/v2_2'
-require 'polyfill/v2_3'
-require 'polyfill/v2_4'
-require 'polyfill/v2_5'
-require 'polyfill/v2_6'
+require_relative 'polyfill/v2_2'
+require_relative 'polyfill/v2_3'
+require_relative 'polyfill/v2_4'
+require_relative 'polyfill/v2_5'
+require_relative 'polyfill/v2_6'