missingly 0.0.2 → 0.0.3
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/lib/missingly/matchers.rb +8 -8
- data/lib/missingly/version.rb +1 -1
- data/spec/class_inheritance_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e73ef19743d5de0709594ea3d67b44efd9133b1b
|
4
|
+
data.tar.gz: 2222043ca754451ccce39090da828b563222cbbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e07f530971e2cb1dab180932d9d2c4e9ce00d367d0816c73ab03cbc15f066e439e42c056aba4a482495b04fb7c02ce2181c1fb222c5bc1cc3fcb29885a9593f2
|
7
|
+
data.tar.gz: 06e156883e936d8fe6963c71e9f40aea08ff3f2ea476b1cc7bb7786ef21e2e6d2695bedba308e72f2f64c6478b56443249bb3c0ad85d0c7cbe8f6385a3f26abd
|
data/lib/missingly/matchers.rb
CHANGED
@@ -3,13 +3,13 @@ module Missingly
|
|
3
3
|
module ClassMethods
|
4
4
|
def handle_missingly(regular_expression_or_array, options={}, &block)
|
5
5
|
case regular_expression_or_array
|
6
|
-
when Array then missingly_matchers
|
7
|
-
when Regexp then missingly_matchers
|
6
|
+
when Array then missingly_matchers[regular_expression_or_array] = ArrayMatcher.new(regular_expression_or_array, options, block)
|
7
|
+
when Regexp then missingly_matchers[regular_expression_or_array] = RegexMatcher.new(regular_expression_or_array, options, block)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def missingly_matchers
|
12
|
-
@missingly_matchers ||=
|
12
|
+
@missingly_matchers ||= {}
|
13
13
|
end
|
14
14
|
|
15
15
|
def _define_method(*args, &block)
|
@@ -17,15 +17,15 @@ module Missingly
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def inherited(subclass)
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
matchers = self.missingly_matchers
|
21
|
+
subclass.module_eval do
|
22
|
+
@missingly_matchers = matchers.clone
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def respond_to_missing?(method_name, include_all)
|
28
|
-
self.class.missingly_matchers.each do |matcher|
|
28
|
+
self.class.missingly_matchers.values.each do |matcher|
|
29
29
|
return true if matcher.should_respond_to?(method_name.to_sym)
|
30
30
|
end
|
31
31
|
super
|
@@ -33,7 +33,7 @@ module Missingly
|
|
33
33
|
private :respond_to_missing?
|
34
34
|
|
35
35
|
def method_missing(method_name, *args, &block)
|
36
|
-
self.class.missingly_matchers.each do |matcher|
|
36
|
+
self.class.missingly_matchers.values.each do |matcher|
|
37
37
|
next unless matcher.should_respond_to?(method_name)
|
38
38
|
|
39
39
|
return matcher.handle(self, method_name, *args, &block)
|
data/lib/missingly/version.rb
CHANGED
@@ -20,4 +20,14 @@ describe Missingly::Matchers do
|
|
20
20
|
b = subclass.new
|
21
21
|
b.foo.should eq :foo
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should allow override of parent class" do
|
25
|
+
subclass.module_eval do
|
26
|
+
handle_missingly [:foo] do |method|
|
27
|
+
:super_duper
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
subclass.new.foo.should eq :super_duper
|
32
|
+
end
|
23
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: missingly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thijs de Vries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|