chainable 0.3.2 → 0.3.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.
data/lib/chainable.rb CHANGED
@@ -185,6 +185,18 @@ module Chainable
185
185
  @method_store[method_id].bind(owner).call(*args, &block)
186
186
  end
187
187
 
188
+ def self.raise_potential_errors= value
189
+ @raise_potential_errors = value
190
+ end
191
+
192
+ def self.raise_potential_errors?
193
+ @raise_potential_errors ||= false
194
+ end
195
+
196
+ def self.could_raise(error = Exception)
197
+ raise error if raise_potential_errors?
198
+ end
199
+
188
200
  # Copies a method from one module to another.
189
201
  # TODO: This could be solved totally different in Rubinius.
190
202
  def self.copy_method(source_class, target_class, name)
@@ -196,6 +208,7 @@ module Chainable
196
208
  m = source_class.instance_method name
197
209
  target_class.class_eval do
198
210
  begin
211
+ Chainable.could_raise(SyntaxError) # for specs
199
212
  eval "define_method(name) { |*a, &b| m.bind(self).call(*a, &b) }"
200
213
  rescue SyntaxError # Ruby < 1.8.7, JRuby
201
214
  # Really really evil, have to change it.
@@ -37,8 +37,10 @@ describe "Chainable#chain_method" do
37
37
  it "should work for core methods" do
38
38
  Array.class_eval { chain_method :join }
39
39
  ["hello", "world"].join(" ").should == "hello world"
40
+ Chainable.raise_potential_errors = true
40
41
  String.class_eval { chain_method(:inspect) { "%#{super}" } }
41
42
  "hello world".inspect.should == '%"hello world"'
43
+ Chainable.raise_potential_errors = false
42
44
  end
43
45
 
44
46
  it "should define a new method, when block given" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chainable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -31,24 +31,26 @@ extensions: []
31
31
  extra_rdoc_files:
32
32
  - README.rdoc
33
33
  - LICENSE
34
+ - benchmark/chainable.rb
34
35
  - lib/chainable.rb
35
36
  - spec/chainable/auto_chain_spec.rb
36
- - spec/chainable/merge_method_spec.rb
37
37
  - spec/chainable/chain_method_spec.rb
38
38
  - spec/chainable/chain_method_try_merge_spec.rb
39
- - benchmark/chainable.rb
39
+ - spec/chainable/merge_method_spec.rb
40
40
  files:
41
41
  - LICENSE
42
42
  - Rakefile
43
43
  - README.rdoc
44
+ - benchmark/chainable.rb
44
45
  - lib/chainable.rb
45
46
  - spec/chainable/auto_chain_spec.rb
46
- - spec/chainable/merge_method_spec.rb
47
47
  - spec/chainable/chain_method_spec.rb
48
48
  - spec/chainable/chain_method_try_merge_spec.rb
49
- - benchmark/chainable.rb
49
+ - spec/chainable/merge_method_spec.rb
50
50
  has_rdoc: true
51
51
  homepage: http://rkh.github.com/chainable
52
+ licenses: []
53
+
52
54
  post_install_message:
53
55
  rdoc_options: []
54
56
 
@@ -69,9 +71,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
71
  requirements: []
70
72
 
71
73
  rubyforge_project:
72
- rubygems_version: 1.3.1
74
+ rubygems_version: 1.3.5
73
75
  signing_key:
74
- specification_version: 2
76
+ specification_version: 3
75
77
  summary: never use alias_method_chain, again
76
78
  test_files: []
77
79