Skip to content

Commit 954e70e

Browse files
committed
Refactor
1 parent bc1310f commit 954e70e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ruby_event_store/lib/ruby_event_store/specification.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Specification
2222
) do
2323
def limit? = !limit.infinite?
2424
def with_ids? = !with_ids.nil?
25-
def with_types? = !(with_types || []).empty?
25+
def with_types? = !with_types.nil?
2626
def forward? = direction.equal?(:forward)
2727
def backward? = direction.equal?(:backward)
2828
def batched? = read_as.equal?(:batch)
@@ -313,7 +313,8 @@ def last
313313
# @types [Class, Array(Class)] types of event to look for.
314314
# @return [Specification]
315315
def of_type(*types)
316-
Specification.new(reader, result.with(with_types: types.flatten.map(&:to_s)))
316+
types_ = types.flatten.map(&:to_s) unless types.empty?
317+
Specification.new(reader, result.with(with_types: types_))
317318
end
318319
alias of_types of_type
319320

ruby_event_store/spec/specification_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module RubyEventStore
6868
specify { expect(specification.with_id([]).result.with_ids?).to be(true) }
6969

7070
specify { expect(specification.result.with_types).to be_nil }
71+
specify { expect(specification.of_type.result.with_types).to be_nil }
7172
specify { expect(specification.of_type([TestEvent]).result.with_types).to eq(["TestEvent"]) }
7273
specify { expect(specification.result.with_types?).to be(false) }
7374
specify { expect(specification.of_type([TestEvent]).result.with_types?).to be(true) }

0 commit comments

Comments
 (0)