File tree Expand file tree Collapse file tree 3 files changed +52
-54
lines changed Expand file tree Collapse file tree 3 files changed +52
-54
lines changed Original file line number Diff line number Diff line change 1010require_relative "ruby_event_store/client"
1111require_relative "ruby_event_store/metadata"
1212require_relative "ruby_event_store/specification"
13- require_relative "ruby_event_store/specification_result"
1413require_relative "ruby_event_store/specification_reader"
1514require_relative "ruby_event_store/event"
1615require_relative "ruby_event_store/stream"
Original file line number Diff line number Diff line change 33module RubyEventStore
44 # Used for building and executing the query specification.
55 class Specification
6+ Result =
7+ Data . define (
8+ :direction ,
9+ :start ,
10+ :stop ,
11+ :older_than ,
12+ :older_than_or_equal ,
13+ :newer_than ,
14+ :newer_than_or_equal ,
15+ :time_sort_by ,
16+ :limit ,
17+ :stream ,
18+ :read_as ,
19+ :batch_size ,
20+ :with_ids ,
21+ :with_types ,
22+ ) do
23+ def initialize (
24+ direction : :forward ,
25+ start : nil ,
26+ stop : nil ,
27+ older_than : nil ,
28+ older_than_or_equal : nil ,
29+ newer_than : nil ,
30+ newer_than_or_equal : nil ,
31+ time_sort_by : nil ,
32+ limit : nil ,
33+ stream : Stream . new ( GLOBAL_STREAM ) ,
34+ read_as : :all ,
35+ batch_size : Specification ::DEFAULT_BATCH_SIZE ,
36+ with_ids : nil ,
37+ with_types : nil
38+ )
39+ super
40+ end
41+
42+ def limit? = !to_h [ :limit ] . nil?
43+ def limit = to_h [ :limit ] || Float ::INFINITY
44+ def forward? = direction . equal? ( :forward )
45+ def backward? = direction . equal? ( :backward )
46+ def with_ids? = !with_ids . nil?
47+ def with_types? = !( with_types || [ ] ) . empty?
48+ def batched? = read_as . equal? ( :batch )
49+ def first? = read_as . equal? ( :first )
50+ def last? = read_as . equal? ( :last )
51+ def all? = read_as . equal? ( :all )
52+ def time_sort_by_as_at? = time_sort_by . equal? ( :as_at )
53+ def time_sort_by_as_of? = time_sort_by . equal? ( :as_of )
54+ end
55+
656 DEFAULT_BATCH_SIZE = 100
757
858 # @api private
@@ -315,4 +365,6 @@ def events(event_ids)
315365
316366 attr_reader :reader
317367 end
368+
369+ SpecificationResult = Specification ::Result
318370end
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments