missingly 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c83a64e80420514a8f4339f2339311fa644af8c5
4
- data.tar.gz: 221eb5fa8de4ca6bb84451c5a3b85ffbf50a80f4
3
+ metadata.gz: e73ef19743d5de0709594ea3d67b44efd9133b1b
4
+ data.tar.gz: 2222043ca754451ccce39090da828b563222cbbe
5
5
  SHA512:
6
- metadata.gz: 4d24aa8b5918b3243ed15baf68f7bbada4a779b32ca8dd7d3f5403dc0b6c9c2b2d107f2f72389546cc365024df892f87e39279c011de52da4898103f812d9608
7
- data.tar.gz: fde01f81b25d55f21369f04e52b481c93100b38e4c009d70c517f06006937db76e6e67867251186255953c653791f94afe0ef5f6bf0b2de2982c59f56545a23c
6
+ metadata.gz: e07f530971e2cb1dab180932d9d2c4e9ce00d367d0816c73ab03cbc15f066e439e42c056aba4a482495b04fb7c02ce2181c1fb222c5bc1cc3fcb29885a9593f2
7
+ data.tar.gz: 06e156883e936d8fe6963c71e9f40aea08ff3f2ea476b1cc7bb7786ef21e2e6d2695bedba308e72f2f64c6478b56443249bb3c0ad85d0c7cbe8f6385a3f26abd
@@ -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 << ArrayMatcher.new(regular_expression_or_array, options, block)
7
- when Regexp then missingly_matchers << RegexMatcher.new(regular_expression_or_array, options, block)
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
- subclass.extend Missingly::Matchers::ClassMethods
21
- self.missingly_matchers.each do |matcher|
22
- subclass.missingly_matchers << matcher
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)
@@ -1,3 +1,3 @@
1
1
  module Missingly
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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.2
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 00:00:00.000000000 Z
11
+ date: 2013-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler