Skip to content

Commit df61a2c

Browse files
style(Style/OpenStructUse): manual
1 parent 511572c commit df61a2c

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,6 @@ Style/MultilineBlockChain:
828828
- 'spec/mongoid/changeable_spec.rb'
829829
- 'spec/mongoid/document_spec.rb'
830830

831-
# Offense count: 4
832-
Style/OpenStructUse:
833-
Exclude:
834-
- 'lib/mongoid/indexable.rb'
835-
- 'spec/rails/controller_extension/controller_runtime_spec.rb'
836-
- 'spec/support/rails_mock.rb'
837-
838831
# Offense count: 17
839832
# Configuration parameters: AllowedMethods.
840833
# AllowedMethods: respond_to_missing?

lib/mongoid/indexable.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module Indexable
1717

1818
module ClassMethods
1919

20+
IndexSpec = Struct.new(:fields, :key, keyword_init: true)
21+
2022
# Send the actual index creation comments to the MongoDB driver
2123
#
2224
# @example Create the indexes for the class.
@@ -109,7 +111,7 @@ def index(spec, options = nil)
109111
#
110112
# @return [ Specification ] The found specification.
111113
def index_specification(index_hash, index_name = nil)
112-
index = OpenStruct.new(fields: index_hash.keys, key: index_hash)
114+
index = IndexSpec.new(fields: index_hash.keys, key: index_hash)
113115
index_specifications.detect do |spec|
114116
spec == index || (index_name && index_name == spec.name)
115117
end

spec/rails/controller_extension/controller_runtime_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def clear_metric!
4141

4242
describe 'Collector' do
4343

44+
before do
45+
stub_const('EventPayload', Struct.new(:duration, keyword_init: true))
46+
end
47+
4448
it 'stores the metric in thread-safe manner' do
4549
clear_metric!
4650
expect(collector.runtime).to eq(0)
@@ -50,7 +54,7 @@ def clear_metric!
5054

5155
it 'sets metric on both succeeded and failed' do
5256
instance = collector.new
53-
event_payload = OpenStruct.new duration: 42
57+
event_payload = EventPayload.new(duration: 42)
5458

5559
clear_metric!
5660
instance.succeeded event_payload

spec/support/rails_mock.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ def eager_load!; end
1919
end
2020
end
2121

22+
ConfigPaths = Struct.new(:expanded, keyword_init: true)
23+
AppConfig = Struct.new(:paths, keyword_init: true)
24+
2225
Rails.env = 'development'
2326
Rails.root = Pathname.new('.')
2427
Rails.logger = Logger.new($stdout)
2528
Rails.application = Rails::Application
2629

27-
Rails.application.config = OpenStruct.new(
28-
paths: { 'app/models' => OpenStruct.new(expanded: ['app/models']) }
30+
Rails.application.config = AppConfig.new(
31+
paths: { 'app/models' => ConfigPaths.new(expanded: ['app/models']) }
2932
)

0 commit comments

Comments
 (0)