2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/including.rb', line 2
def including(mixin, options = {})
include mixin and return unless options[:only] || options[:except]
included_module = mixin.dup
if options[:except]
excluded_methods = options[:except]
undefine(included_module, excluded_methods) and return
else
included_methods = included_module.instance_methods(false)
excluded_methods = Array(options[:only]).map(&:to_sym)
undefine(included_module, included_methods - excluded_methods)
end
end
|