lib/usable.rb in usable-3.8.0 vs lib/usable.rb in usable-3.9.0

- old
+ new

@@ -88,12 +88,14 @@ super end def define_usable_accessors usables.to_h.keys.each do |key| - define_singleton_method(key) { usables[key] } - define_singleton_method("#{key}=") { |new_val| usables[key] = new_val } + define_singleton_method(key) { usables.send(key) } + define_singleton_method("#{key}=") { |new_val| usables.send("#{key}=", new_val) } + define_method(key) { usables.send(key) } + define_method("#{key}=") { |new_val| usables.send("#{key}=", new_val) } end end def usables @usables ||= Config.new @@ -118,11 +120,13 @@ # @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 self def usable(*args, &block) options = args.last.is_a?(Hash) ? args.pop : {} + only = options.delete(:only) + extension_method = options.delete(:method) args.each do |mod| - ModExtender.new(mod, only: options.delete(:only), method: options.delete(:method)).call self + ModExtender.new(mod, only: only, method: extension_method).call self # Define settings on @usables and on the scoped @usables scope = Config.new if mod.name scope_name = mod.name.split('::').last.gsub(/\B([A-Z])([a-z_0-9])/, '_\1\2').downcase usables[scope_name] = scope