lib/usable.rb in usable-2.0.0 vs lib/usable.rb in usable-2.1.0

- old
+ new

@@ -33,13 +33,11 @@ @usables.instance_eval &Proc.new end attr_writer :usables - # @description Configures the +available_methods+ of a module using the given options or block and then includes it on - # the target class. Checks if there is a module named UsableSpec within the given mods namespace and uses the instance - # methods of that as the +available_methods+ + # @description Includes the given module with a set of options or block to configure it # # @example # # class Example # extend Usable @@ -47,13 +45,10 @@ # baz "Available as `Example.usables.baz` or `Example.usables.mixin.baz`" # end # end # # @note Hides methods - # @note We include the primary mod when there is a UsableSpec set because any instance methods defined on the mod are - # not configurable and should therefore takes precedence over those defined in the UsableSpec - # # @param [Module] mod # @param [Hash] options Customize the extension of the module as well as define config settings on the target # @option [Array,Symbol] :only Limit which methods are copied from the module # @option [String,Symbol] :method (:include) The method to use for including the module # @return [ModExtender] containing the original and modified module @@ -70,15 +65,13 @@ [scope, usables].each { |x| x.spec k, v } end end [scope, usables].each { |x| options.each { |k, v| x[k] = v } } [scope, usables].each { |x| x.instance_eval &block } if block_given? - # Include module - mod_ext = ModExtender.new mod, usable_options - mod_ext.use! self - mod_ext.use_original! self - mod_ext.use_class_methods! self - mod_ext + ModExtender.new(mod, usable_options).call self + self.include mod.const_get(:InstanceMethods) if self.const_defined? :InstanceMethods + self.extend mod.const_get(:ClassMethods) if self.const_defined? :ClassMethods + self end # @return [Method] bound to the given -context- def usable_method(context, method_name) usables.available_methods[method_name].bind(context)