diff --git a/lib/chewy/fields/root.rb b/lib/chewy/fields/root.rb index d6e125ba8..e821cb9ca 100644 --- a/lib/chewy/fields/root.rb +++ b/lib/chewy/fields/root.rb @@ -4,7 +4,7 @@ class Root < Chewy::Fields::Base attr_reader :dynamic_templates, :id def initialize(name, **options) - super(name, **options) + super @value ||= -> { self } @dynamic_templates = [] diff --git a/spec/chewy/fields/base_spec.rb b/spec/chewy/fields/base_spec.rb index bd8149bd6..cf82bde2a 100644 --- a/spec/chewy/fields/base_spec.rb +++ b/spec/chewy/fields/base_spec.rb @@ -5,7 +5,7 @@ specify { expect(described_class.new('name', type: 'integer').options[:type]).to eq('integer') } describe '#compose' do - let(:field) { described_class.new(:name, value: ->(o) { o.value }) } + let(:field) { described_class.new(:name, value: lambda(&:value)) } specify { expect(field.compose(double(value: 'hello'))).to eq(name: 'hello') } specify { expect(field.compose(double(value: %w[hello world]))).to eq(name: %w[hello world]) } @@ -23,7 +23,7 @@ context 'nested fields' do before do - field.children.push(described_class.new(:subname1, value: ->(o) { o.subvalue1 })) + field.children.push(described_class.new(:subname1, value: lambda(&:subvalue1))) field.children.push(described_class.new(:subname2, value: -> { subvalue2 })) field.children.push(described_class.new(:subname3)) end diff --git a/spec/chewy/index/observe/callback_spec.rb b/spec/chewy/index/observe/callback_spec.rb index 825e3b405..84cd6219b 100644 --- a/spec/chewy/index/observe/callback_spec.rb +++ b/spec/chewy/index/observe/callback_spec.rb @@ -21,7 +21,7 @@ end context 'when executable is has arity 1' do - let(:executable) { ->(record) { record.population } } + let(:executable) { lambda(&:population) } it 'calls exectuable within context' do expect(callback.call(city)).to eq(city.population)