deferrable_gratification 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -139,7 +139,7 @@ module DeferrableGratification
|
|
139
139
|
# @example Retrieve a web page and call back with its title.
|
140
140
|
# HTTP.request(url).transform {|page| Hpricot(page).at(:title).inner_html }
|
141
141
|
def transform(&block)
|
142
|
-
|
142
|
+
Bind.setup!(self, :without_chaining => true, &block)
|
143
143
|
end
|
144
144
|
|
145
145
|
# Transform the value passed to the errback of this Deferrable by invoking
|
@@ -43,9 +43,13 @@ module DeferrableGratification
|
|
43
43
|
# @param &block block to run on success; should return a Deferrable.
|
44
44
|
#
|
45
45
|
# @raise [ArgumentError] if called without a block.
|
46
|
-
def initialize(first, &block)
|
46
|
+
def initialize(first, options = {}, &block)
|
47
47
|
@first = first
|
48
48
|
|
49
|
+
@with_chaining = !options.delete(:without_chaining)
|
50
|
+
bad_keys = options.keys.join(', ')
|
51
|
+
raise "Unknown options: #{bad_keys}" unless bad_keys.empty?
|
52
|
+
|
49
53
|
raise ArgumentError, 'must pass a block' unless block
|
50
54
|
@proc = block
|
51
55
|
end
|
@@ -64,8 +68,8 @@ module DeferrableGratification
|
|
64
68
|
# @return [Bind] Deferrable representing the compound operation.
|
65
69
|
#
|
66
70
|
# @raise (see #initialize)
|
67
|
-
def self.setup!(first, &block)
|
68
|
-
new(first, &block).tap(&:setup!)
|
71
|
+
def self.setup!(first, options = {}, &block)
|
72
|
+
new(first, options, &block).tap(&:setup!)
|
69
73
|
end
|
70
74
|
|
71
75
|
private
|
@@ -79,7 +83,7 @@ module DeferrableGratification
|
|
79
83
|
# callbacks. However, as referred to in the class comment above, we
|
80
84
|
# can't assume that it will, and need to behave sensibly if it
|
81
85
|
# doesn't.
|
82
|
-
if second.respond_to?(:callback) && second.respond_to?(:errback)
|
86
|
+
if @with_chaining && second.respond_to?(:callback) && second.respond_to?(:errback)
|
83
87
|
second.callback {|*args2| self.succeed(*args2) }
|
84
88
|
second.errback {|*error| self.fail(*error) }
|
85
89
|
else
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deferrable_gratification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Stokes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-20 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements: []
|
153
153
|
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.
|
155
|
+
rubygems_version: 1.3.7
|
156
156
|
signing_key:
|
157
157
|
specification_version: 3
|
158
158
|
summary: Makes evented programming easier with composition and abstraction.
|