lib/usable.rb in usable-2.1.3 vs lib/usable.rb in usable-2.2.0
- old
+ new
@@ -59,18 +59,26 @@
if mod.name
scope_name = mod.name.split('::').last.gsub(/\B([A-Z])([a-z_0-9])/, '_\1\2').downcase
usables[scope_name] = scope
end
if mod.respond_to? :usables
- mod.usables.each do |k, v|
- [scope, usables].each { |x| x.spec k, v }
- end
+ scope += mod.usables
+ self.usables += mod.usables
end
- [scope, usables].each { |x| options.each { |k, v| x[k] = v } }
- [scope, usables].each { |x| x.instance_eval &block } if block_given?
+ # any left over -options- are considered "config" settings
+ if options
+ [scope, usables].each { |x| options.each { |k, v| x[k] = v } }
+ end
+ if block_given?
+ [scope, usables].each { |x| x.instance_eval &block }
+ end
+ if mod.const_defined?(:InstanceMethods)
+ send :include, mod.const_get(:InstanceMethods)
+ end
+ if mod.const_defined?(:ClassMethods)
+ send :extend, mod.const_get(:ClassMethods)
+ end
ModExtender.new(mod, usable_options).call self
- send :include, mod.const_get(:InstanceMethods) if mod.const_defined?(:InstanceMethods)
- send :extend, mod.const_get(:ClassMethods) if mod.const_defined?(:ClassMethods)
self
end
# @return [Method] bound to the given -context-
def usable_method(context, method_name)