Skip to content

Commit a79052a

Browse files
committed
Rename Promise#collect to #trace
1 parent 09e084c commit a79052a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

spec/opal/stdlib/promise/collect_spec.rb renamed to spec/opal/stdlib/promise/trace_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
require 'promise'
22

3-
describe 'Promise#collect' do
3+
describe 'Promise#trace' do
44
it 'calls the block with all the previous results' do
55
x = 42
66

7-
Promise.value(1).then { 2 }.then { 3 }.collect {|a, b, c|
7+
Promise.value(1).then { 2 }.then { 3 }.trace {|a, b, c|
88
x = a + b + c
99
}
1010

1111
x.should == 6
1212
end
1313

14-
it 'calls the then after the collect' do
14+
it 'calls the then after the trace' do
1515
x = 42
1616

17-
Promise.value(1).then { 2 }.then { 3 }.collect {|a, b, c|
17+
Promise.value(1).then { 2 }.then { 3 }.trace {|a, b, c|
1818
a + b + c
1919
}.then { |v| x = v }
2020

@@ -26,7 +26,7 @@
2626

2727
Promise.value(1).then {
2828
Promise.when Promise.value(2), Promise.value(3)
29-
}.collect {|a, b|
29+
}.trace {|a, b|
3030
x = a + b[0] + b[1]
3131
}
3232

stdlib/promise.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def always(&block)
174174
alias finally always
175175
alias ensure always
176176

177-
def collect(&block)
178-
self ^ Collect.new(block)
177+
def trace(&block)
178+
self ^ Trace.new(block)
179179
end
180180

181181
def inspect
@@ -194,7 +194,7 @@ def inspect
194194
result
195195
end
196196

197-
class Collect < self
197+
class Trace < self
198198
def self.it(promise)
199199
unless promise.realized?
200200
raise ArgumentError, "the promise hasn't been realized"
@@ -211,7 +211,7 @@ def self.it(promise)
211211

212212
def initialize(block)
213213
super -> {
214-
block.call(*Collect.it(self).reverse)
214+
block.call(*Trace.it(self).reverse)
215215
}
216216
end
217217
end

0 commit comments

Comments
 (0)