kungfuig 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/lib/kungfuig.rb +2 -2
- data/lib/kungfuig/aspector.rb +4 -2
- data/lib/kungfuig/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7209ee253dbd083df7df4be1c0596cf3be0b45eb
|
4
|
+
data.tar.gz: 9cb680779c32389e770bceb047b4440c5e39c423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ce51cdf63d82c08b78305427e23b1c6721533e5486bc7416ab9d9f3cf774b5fabf74af09c35b3385f0371a4c5c818c35e07b7f3c180e7c825d4411f93f3846
|
7
|
+
data.tar.gz: 654e3a115be6951f928a4e56441668eaad7b3f49f224dd3ee5f463a4eb2b5fbfb1c8098c5bb48daeb783c8a5e18132caa16b53b645a6467c872d63a635b5b08e
|
data/.rubocop.yml
CHANGED
data/lib/kungfuig.rb
CHANGED
@@ -124,11 +124,11 @@ module Kungfuig
|
|
124
124
|
|
125
125
|
aspects(meth)[after ? :after : :before] << Proc.new
|
126
126
|
|
127
|
-
unless instance_methods
|
127
|
+
unless instance_methods.include?(:"#{ASPECT_PREFIX}#{meth}")
|
128
128
|
class_eval <<-CODE
|
129
129
|
alias_method :#{ASPECT_PREFIX}#{meth}, :#{meth}
|
130
130
|
def #{meth}(*args, &cb)
|
131
|
-
ps = self.class.aspects(:#{meth})
|
131
|
+
ps = self.class.aspects(:#{meth}).merge((class << self; self; end).aspects(:#{meth})) { |_, c, ec| c | ec }
|
132
132
|
ps[:before].each do |p|
|
133
133
|
p.call(*args) # TODO: make prependers able to change args!!!
|
134
134
|
end
|
data/lib/kungfuig/aspector.rb
CHANGED
@@ -11,15 +11,17 @@ module Kungfuig
|
|
11
11
|
case
|
12
12
|
when v.empty? then []
|
13
13
|
when v.include?(:'*') then klazz.instance_methods(false)
|
14
|
-
else klazz.instance_methods
|
14
|
+
else klazz.instance_methods & v
|
15
15
|
end
|
16
16
|
end.reduce(&:-)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def attach(
|
20
|
+
def attach(to, before: nil, after: nil, exclude: nil)
|
21
21
|
raise ArgumentError, "Trying to attach nothing to #{klazz}. I need a block!" unless block_given?
|
22
22
|
|
23
|
+
klazz = to.is_a?(Class) ? to : class << to; self; end # attach to klazz’s eigenclass if object given
|
24
|
+
|
23
25
|
klazz.send(:include, Kungfuig::Aspector) unless klazz.ancestors.include? Kungfuig::Aspector
|
24
26
|
cb = Proc.new
|
25
27
|
|
data/lib/kungfuig/version.rb
CHANGED