Skip to content

Commit

Permalink
Fixed all deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Seddon committed May 21, 2020
1 parent de2f06c commit f31a5c7
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/chewy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def derive_types(from)
def create_type(index, target, options = {}, &block)
type = Class.new(Chewy::Type)

adapter = adapters.find { |klass| klass.accepts?(target) }.new(target, options)
adapter = adapters.find { |klass| klass.accepts?(target) }.new(target, **options)

index.const_set(adapter.name, type)
type.send(:define_singleton_method, :index) { index }
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/fields/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Base
def initialize(name, value: nil, **options)
@name = name.to_sym
@options = {}
update_options!(options)
update_options!(**options)
@value = value
@children = []
end
Expand Down
4 changes: 2 additions & 2 deletions lib/chewy/fields/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Root < Chewy::Fields::Base
attr_reader :parent
attr_reader :parent_id

def initialize(*)
super
def initialize(name, **options)
super(name, **options)

@value ||= -> { self }
@dynamic_templates = []
Expand Down
8 changes: 4 additions & 4 deletions lib/chewy/type/mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module ClassMethods
# end
#
def root(**options)
self.root_object ||= Chewy::Fields::Root.new(type_name, Chewy.default_root_options.merge(options))
root_object.update_options!(options)
self.root_object ||= Chewy::Fields::Root.new(type_name, **Chewy.default_root_options.merge(options))
root_object.update_options!(**options)
yield if block_given?
root_object
end
Expand Down Expand Up @@ -126,9 +126,9 @@ def root(**options)
#
def field(*args, **options, &block)
if args.size > 1
args.map { |name| field(name, options) }
args.map { |name| field(name, **options) }
else
expand_nested(Chewy::Fields::Base.new(args.first, options), &block)
expand_nested(Chewy::Fields::Base.new(args.first, **options), &block)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Chewy
VERSION = '5.1.0'.freeze
VERSION = '5.1.1'.freeze
end
2 changes: 1 addition & 1 deletion spec/chewy/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
context 'when Rails::VERSION constant is defined' do
it 'looks for configuration in "config/chewy.yml"' do
module Rails
VERSION = '5.1.0'.freeze
VERSION = '5.1.1'.freeze

def self.root
Pathname.new(__dir__)
Expand Down
2 changes: 1 addition & 1 deletion spec/chewy/journal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def timestamp(time)
expect(Chewy::Stash::Journal.exists?).to eq true

Timecop.freeze(update_time)
cities.first.update_attributes!(name: 'Supername')
cities.first.update!(name: 'Supername')

Timecop.freeze(destroy_time)
countries.last.destroy
Expand Down
2 changes: 1 addition & 1 deletion spec/chewy/type/import/bulk_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
context 'updating parent' do
before do
PlacesIndex::City.import(city)
city.update_attributes(country_id: another_country.id)
city.update(country_id: another_country.id)
end
let(:index) { [city] }

Expand Down
8 changes: 4 additions & 4 deletions spec/chewy/type/observe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
specify { expect { city.save! }.to update_index('cities#city').and_reindex(city).only }
specify { expect { city.save! }.to update_index('countries#country').and_reindex(country1).only }

specify { expect { city.update_attributes!(country: nil) }.to update_index('cities#city').and_reindex(city).only }
specify { expect { city.update_attributes!(country: nil) }.to update_index('countries#country').and_reindex(country1).only }
specify { expect { city.update!(country: nil) }.to update_index('cities#city').and_reindex(city).only }
specify { expect { city.update!(country: nil) }.to update_index('countries#country').and_reindex(country1).only }

specify { expect { city.update_attributes!(country: country2) }.to update_index('cities#city').and_reindex(city).only }
specify { expect { city.update_attributes!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2).only }
specify { expect { city.update!(country: country2) }.to update_index('cities#city').and_reindex(city).only }
specify { expect { city.update!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2).only }
end

context do
Expand Down

0 comments on commit f31a5c7

Please # to comment.