Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,6 @@ Style/CollectionQuerying:
Enabled: true
Lint/AmbiguousRange:
Enabled: true

Style/OneClassPerFile:
Enabled: false
2 changes: 1 addition & 1 deletion lib/sequent/core/active_projectors_event_publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def process_events(event_handlers, ...)

def ensure_no_unknown_active_projectors!(event_handlers)
registered_projectors = event_handlers
.select { |x| x.is_a?(Projector) }
.grep(Projector)
.map { |x| x.class.name }
activated_projectors = Projectors.projector_states
.values
Expand Down
2 changes: 1 addition & 1 deletion lib/sequent/core/event_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def event_streams_enumerator(aggregate_type: nil, group_size: 100)
end

def update_unique_keys(event_streams)
fail ArgumentError, 'array of stream records expected' unless event_streams.all? { |x| x.is_a?(EventStream) }
fail ArgumentError, 'array of stream records expected' unless event_streams.all?(EventStream)

call_procedure(connection, 'update_unique_keys', [event_streams.to_json])
rescue ActiveRecord::RecordNotUnique => e
Expand Down
2 changes: 1 addition & 1 deletion lib/sequent/core/helpers/unique_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module ClassMethods
# ```
def unique_key(scope, *attributes, **kwargs)
fail ArgumentError, "'#{scope}' is not a symbol" unless scope.is_a?(Symbol)
fail ArgumentError, 'attributes must be symbols' unless attributes.all? { |attr| attr.is_a?(Symbol) }
fail ArgumentError, 'attributes must be symbols' unless attributes.all?(Symbol)

@unique_key_definitions ||= {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def hash

def struct_cache
@struct_cache ||= Hash.new do |hash, record_class|
struct_class = Struct.new(*record_class.column_names.map(&:to_sym), keyword_init: true) do
struct_class = Struct.new(*record_class.column_names.map(&:to_sym)) do
include InMemoryStruct
end
hash[record_class] = struct_class
Expand Down
4 changes: 2 additions & 2 deletions lib/sequent/core/projector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def version = projector_version || Sequent.migrations_class&.version || 1
end

def self.projectors
Sequent.configuration.event_handlers.select { |x| x.is_a? Migratable }.map(&:class)
Sequent.configuration.event_handlers.grep(Migratable).map(&:class)
end

def self.included(host_class)
Expand Down Expand Up @@ -187,7 +187,7 @@ def ensure_record_class_supported!(record_class)
def ensure_valid!
if self.class.managed_tables.nil?
fail <<~EOS.chomp
A Projector must manage at least one table. Did you forget to add `managed_tables` to #{self.class.name}?
A Projector must manage at least one table. Did you forget to add `managed_tables` to #{self.class}?
EOS
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/sequent/core/projector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ class MyOtherProjectorTable
context 'versioning' do
let(:parent_projector_class) do
Class.new(Sequent::Core::Projector) do
manages_no_tables
self.version = 3
end
end

it 'should default to 1 if not specified' do
projector_class = Class.new(Sequent::Core::Projector)
projector_class = Class.new(Sequent::Core::Projector) { manages_no_tables }

expect(projector_class.version).to eq(1)
end
Expand Down