class RubyEventStore::SpecificationResult
Attributes
Public Class Methods
# File lib/ruby_event_store/specification_result.rb, line 5 def initialize( direction: :forward, start: nil, stop: nil, older_than: nil, older_than_or_equal: nil, newer_than: nil, newer_than_or_equal: nil, time_sort_by: nil, count: nil, stream: Stream.new(GLOBAL_STREAM), read_as: :all, batch_size: Specification::DEFAULT_BATCH_SIZE, with_ids: nil, with_types: nil ) @attributes = Struct .new( :direction, :start, :stop, :older_than, :older_than_or_equal, :newer_than, :newer_than_or_equal, :time_sort_by, :count, :stream, :read_as, :batch_size, :with_ids, :with_types ) .new( direction, start, stop, older_than, older_than_or_equal, newer_than, newer_than_or_equal, time_sort_by, count, stream, read_as, batch_size, with_ids, with_types ) freeze end
Public Instance Methods
Two specification attributess are equal if:
-
they are of the same class
-
have identical data (verified with eql? method)
@param other_spec [SpecificationResult, Object] object to compare
@return [TrueClass, FalseClass]
# File lib/ruby_event_store/specification_result.rb, line 259 def ==(other_spec) other_spec.hash.eql?(hash) end
Read strategy. True if all items will be read {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 222 def all? attributes.read_as.equal?(:all) end
Read direction. True is reading backward {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 150 def backward? get_direction.equal?(:backward) end
Size of batch to read (only for :batch read strategy) {railseventstore.org/docs/read/ Find out more}.
@return [Integer]
# File lib/ruby_event_store/specification_result.rb, line 158 def batch_size attributes.batch_size end
Read strategy. True if items will be read in batches {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 198 def batched? attributes.read_as.equal?(:batch) end
Clone [SpecificationResult] If block is given cloned attributes might be modified.
@return [SpecificationResult]
# File lib/ruby_event_store/specification_result.rb, line 246 def dup new_attributes = attributes.dup yield new_attributes if block_given? SpecificationResult.new(**new_attributes.to_h) end
Read strategy. True if first item will be read {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 206 def first? attributes.read_as.equal?(:first) end
Read direction. True is reading forward {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 142 def forward? get_direction.equal?(:forward) end
Generates a Fixnum hash value for this object. This function have the property that a.eql?(b) implies a.hash == b.hash.
The hash value is used along with eql? by the Hash class to determine if two objects reference the same hash key.
This hash is based on
-
class
-
direction
-
start
-
stop
-
count
-
stream
-
read_as
@return [Integer]
# File lib/ruby_event_store/specification_result.rb, line 287 def hash [ get_direction, start, stop, older_than, older_than_or_equal, newer_than, newer_than_or_equal, time_sort_by, limit, stream, attributes.read_as, batch_size, with_ids, with_types ].hash ^ self.class.hash end
Read strategy. True if last item will be read {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 214 def last? attributes.read_as.equal?(:last) end
Results limit or infinity if limit not defined {railseventstore.org/docs/read/ Find out more}.
@return [Integer|Infinity]
# File lib/ruby_event_store/specification_result.rb, line 70 def limit attributes.count || Float::INFINITY end
Limited results. True if number of read elements are limited {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 62 def limit? !attributes.count.nil? end
Starting time. {railseventstore.org/docs/read/ Find out more}.
@return [Time]
# File lib/ruby_event_store/specification_result.rb, line 118 def newer_than attributes.newer_than end
Starting time. {railseventstore.org/docs/read/ Find out more}.
@return [Time]
# File lib/ruby_event_store/specification_result.rb, line 126 def newer_than_or_equal attributes.newer_than_or_equal end
Ending time. {railseventstore.org/docs/read/ Find out more}.
@return [Time]
# File lib/ruby_event_store/specification_result.rb, line 102 def older_than attributes.older_than end
Ending time. {railseventstore.org/docs/read/ Find out more}.
@return [Time]
# File lib/ruby_event_store/specification_result.rb, line 110 def older_than_or_equal attributes.older_than_or_equal end
Starting position. Event
id of starting event {railseventstore.org/docs/read/ Find out more}.
@return [String]
# File lib/ruby_event_store/specification_result.rb, line 86 def start attributes.start end
Stop position. Event
id of stopping event {railseventstore.org/docs/read/ Find out more}.
@return [String|Symbol]
# File lib/ruby_event_store/specification_result.rb, line 94 def stop attributes.stop end
Stream
definition. Stream
to be read or nil {railseventstore.org/docs/read/ Find out more}.
@return [Stream|nil]
# File lib/ruby_event_store/specification_result.rb, line 78 def stream attributes.stream end
Time sorting strategy. Nil when not specified. {railseventstore.org/docs/read/ Find out more}.
@return [Symbol]
# File lib/ruby_event_store/specification_result.rb, line 134 def time_sort_by attributes.time_sort_by end
Read strategy. True if results will be sorted by timestamp {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 230 def time_sort_by_as_at? time_sort_by.equal?(:as_at) end
Read strategy. True if results will be sorted by valid_at {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 238 def time_sort_by_as_of? time_sort_by.equal?(:as_of) end
Ids of specified event to be read (if any given) {railseventstore.org/docs/read/ Find out more}.
@return [Array|nil]
# File lib/ruby_event_store/specification_result.rb, line 166 def with_ids attributes.with_ids end
Read by specified ids. True if event ids have been specified. {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 174 def with_ids? !with_ids.nil? end
Event
types to be read (if any given) {railseventstore.org/docs/read/ Find out more}.
@return [Array|nil]
# File lib/ruby_event_store/specification_result.rb, line 182 def with_types attributes.with_types&.map(&:to_s) end
Read by specified event types. True if event types have been specified. {railseventstore.org/docs/read/ Find out more}.
@return [Boolean]
# File lib/ruby_event_store/specification_result.rb, line 190 def with_types? !(with_types || []).empty? end
Private Instance Methods
# File lib/ruby_event_store/specification_result.rb, line 310 def get_direction attributes.direction end