Skip to content

[MODEL] Remove deprecation warning and functionality for Single Table Inheritance #900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2019
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
25 changes: 0 additions & 25 deletions elasticsearch-model/lib/elasticsearch/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,36 +172,11 @@ def search(query_or_payload, models=[], options={})
Response::Response.new(models, request)
end

# Check if inheritance is enabled
#
# @note Inheritance is disabled by default.
#
def inheritance_enabled
@settings[:inheritance_enabled] ||= false
end

# Enable inheritance of index_name and document_type
#
# @example Enable inheritance
#
# Elasticsearch::Model.inheritance_enabled = true
#
def inheritance_enabled=(inheritance_enabled)
warn STI_DEPRECATION_WARNING if inheritance_enabled
@settings[:inheritance_enabled] = inheritance_enabled
end

# Access the module settings
#
def settings
@settings ||= {}
end

private

STI_DEPRECATION_WARNING = "DEPRECATION WARNING: Support for Single Table Inheritance (STI) is deprecated " +
"and will be removed in version 7.0.0.\nPlease save different model documents in separate indices and refer " +
"to the Elasticsearch documentation for more information.".freeze
end
extend ClassMethods

Expand Down
16 changes: 1 addition & 15 deletions elasticsearch-model/lib/elasticsearch/model/naming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,7 @@ def document_type=(name)
private

def implicit(prop)
value = nil

if Elasticsearch::Model.settings[:inheritance_enabled]
self.ancestors.each do |klass|
# When Naming is included in Proxy::ClassMethods the actual model
# is among its ancestors. We don't want to call the actual model
# since it will result in the same call to the same instance of
# Proxy::ClassMethods. To prevent this we also skip the ancestor
# that is the target.
next if klass == self || self.respond_to?(:target) && klass == self.target
break if value = klass.respond_to?(prop) && klass.send(prop)
end
end

value || self.send("default_#{prop}")
self.send("default_#{prop}")
end

def default_index_name
Expand Down
25 changes: 0 additions & 25 deletions elasticsearch-model/spec/elasticsearch/model/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,5 @@ def self.search(query, options={})
expect(Elasticsearch::Model.settings[:foo]).to eq('bar')
end
end

context 'when \'inheritance_enabled\' is set' do

around do |example|
original_value = Elasticsearch::Model.settings[:inheritance_enabled]
example.run
Elasticsearch::Model.settings[:inheritance_enabled] = original_value
end

context 'when \'inheritance_enabled\' is true' do

it 'warns with a deprecation message' do
expect(Elasticsearch::Model).to receive(:warn)
Elasticsearch::Model.inheritance_enabled = true
end
end

context 'when \'inheritance_enabled\' is false' do

it 'does not warn' do
expect(Elasticsearch::Model).not_to receive(:warn)
Elasticsearch::Model.inheritance_enabled = false
end
end
end
end
end

This file was deleted.