diff --git a/lib/mobility.rb b/lib/mobility.rb index 65c05026b..71d5e89f1 100644 --- a/lib/mobility.rb +++ b/lib/mobility.rb @@ -85,8 +85,6 @@ def extended(model_class) model_class.extend Translates model_class.extend ClassMethods - #TODO: Remove in v1.0 - model_class.include InstanceMethods if translates = Mobility.config.accessor_method model_class.singleton_class.send(:alias_method, translates, :mobility_accessor) @@ -183,12 +181,6 @@ def get_class_from_key(parent_class, key) end end - # TODO: Remove in v1.0 - def default_fallbacks(*args) - config.public_send(:default_fallbacks, *args) - end - - # TODO: Make private in v1.0 def new_fallbacks(*args) config.public_send(:new_fallbacks, *args) end @@ -235,17 +227,7 @@ def normalize_locale_accessor(attribute, locale = Mobility.locale) # @param [String,Symbol] locale # @raise [InvalidLocale] if locale is present but not available def enforce_available_locales!(locale) - # TODO: Remove conditional in v1.0 - if I18n.enforce_available_locales - raise Mobility::InvalidLocale.new(locale) unless (locale.nil? || available_locales.include?(locale.to_sym)) - else - warn <<-EOL -WARNING: You called Mobility.enforce_available_locales! in a situation where -I18n.enforce_available_locales is false. In the past, Mobility would do nothing -in this case, but as of the next major release Mobility will ignore the I18n -setting and enforce available locales whenever this method is called. -EOL - end + raise Mobility::InvalidLocale.new(locale) unless (locale.nil? || available_locales.include?(locale.to_sym)) end # Returns available locales. Defaults to I18n.available_locales, but will @@ -277,33 +259,6 @@ def set_locale(locale) end end - # TODO: Remove entire module in v1.0 - module InstanceMethods - # Fetch backend for an attribute - # @deprecated Use mobility_backends[:] instead. - # @param [String] attribute Attribute - def mobility_backend_for(attribute) - warn %{ -WARNING: mobility_backend_for is deprecated and will be removed in the next -version of Mobility. Use ._backend instead.} - mobility_backends[attribute.to_sym] - end - - def mobility - warn %{ -WARNING: .mobility is deprecated and will be removed in the next -version of Mobility. To get backends, use ._backend instead.} - @mobility ||= Adapter.new(self) - end - - class Adapter < Struct.new(:model) - def backend_for(attribute) - model.mobility_backends[attribute.to_sym] - end - end - private_constant :Adapter - end - module ClassMethods # Return translated attribute names on this model. # @return [Array] Attribute names diff --git a/lib/mobility/backends/key_value.rb b/lib/mobility/backends/key_value.rb index 9f2e18f24..03013bc6a 100644 --- a/lib/mobility/backends/key_value.rb +++ b/lib/mobility/backends/key_value.rb @@ -98,14 +98,7 @@ def configure(options) options[:association_name] &&= options[:association_name].to_sym options[:class_name] &&= Util.constantize(options[:class_name]) if !(options[:type] || (options[:class_name] && options[:association_name])) - # TODO: Remove warning and raise ArgumentError in v1.0 - warn %{ -WARNING: In previous versions, the Mobility KeyValue backend defaulted to a -text type column, but this behavior is now deprecated and will be removed in -the next release. Either explicitly specify the type by passing type: :text in -each translated model, or set a default option in your configuration. - } - options[:type] = :text + raise ArgumentError, "KeyValue backend requires an explicit type option, either text or string." end end diff --git a/lib/mobility/configuration.rb b/lib/mobility/configuration.rb index 1fc0aa972..854038dee 100644 --- a/lib/mobility/configuration.rb +++ b/lib/mobility/configuration.rb @@ -23,24 +23,6 @@ class Configuration # @return [Hash] attr_reader :default_options - # @deprecated The default_options= setter has been deprecated. Set each - # option on the default_options hash instead. - def default_options=(options) - warn %{ -WARNING: The default_options= setter has been deprecated. -Set each option on the default_options hash instead, like this: - - config.default_options[:fallbacks] = { ... } - config.default_options[:dirty] = true -} - if (keys = options.keys & RESERVED_OPTION_KEYS).present? - raise ReservedOptionKey, - "Default options may not contain the following reserved keys: #{keys.join(', ')}" - else - @default_options = options - end - end - # @param [Symbol] name Plugin name def plugin(name) attributes_class.plugin(name) @@ -68,26 +50,6 @@ def new_fallbacks(fallbacks = {}) # @param [Proc] fallbacks generator attr_writer :fallbacks_generator - # @deprecated Use {#new_fallbacks} instead. - def default_fallbacks(fallbacks = {}) - warn %{ -WARNING: The default_fallbacks configuration getter has been renamed -new_fallbacks to avoid confusion. The original method default_fallbacks will be -removed in the next major version of Mobility. -} - new_fallbacks(fallbacks) - end - - # @deprecated Use {#fallbacks_generator=} instead. - def default_fallbacks=(fallbacks) - warn %{ -WARNING: The default_fallbacks= configuration setter has been renamed -fallbacks_generator= to avoid confusion. The original method -default_fallbacks= will be removed in the next major version of Mobility. -} - self.fallbacks_generator = fallbacks - end - # Default backend to use (can be symbol or actual backend class) # @return [Symbol,Class] attr_accessor :default_backend diff --git a/spec/mobility/backends/key_value_spec.rb b/spec/mobility/backends/key_value_spec.rb index 6b942754d..cc23c5c04 100644 --- a/spec/mobility/backends/key_value_spec.rb +++ b/spec/mobility/backends/key_value_spec.rb @@ -8,12 +8,12 @@ klass end - it "issues warning if type is not defined, and class_name and association_name are also not defined" do + it "raises ArgumentError if type is not defined, and class_name and association_name are also not defined" do stub_const("Foo", Class.new) - error_regex = /#{%{WARNING: In previous versions, the Mobility KeyValue backend defaulted to a}}/ - expect { backend_class.configure({}) }.to output(error_regex).to_stderr - expect { backend_class.configure(class_name: "Foo") }.to output(error_regex).to_stderr - expect { backend_class.configure(association_name: "foos") }.to output(error_regex).to_stderr + error_msg = /KeyValue backend requires an explicit type option/ + expect { backend_class.configure({}) }.to raise_error(ArgumentError, error_msg) + expect { backend_class.configure(class_name: "Foo") }.to raise_error(ArgumentError, error_msg) + expect { backend_class.configure(association_name: "foos") }.to raise_error(ArgumentError, error_msg) end end end diff --git a/spec/mobility/configuration_spec.rb b/spec/mobility/configuration_spec.rb index 569cc02d3..ea880617b 100644 --- a/spec/mobility/configuration_spec.rb +++ b/spec/mobility/configuration_spec.rb @@ -5,7 +5,6 @@ it "initializes new fallbacks instance to I18n::Locale::Fallbacks.new" do expect(subject.new_fallbacks).to be_a(I18n::Locale::Fallbacks) - expect(subject.default_fallbacks).to be_a(I18n::Locale::Fallbacks) # TODO: remove in v1.0 end it "initializes default accessor_locales to I18n.available_locales" do diff --git a/spec/mobility_spec.rb b/spec/mobility_spec.rb index b2e37c859..33490dfa6 100644 --- a/spec/mobility_spec.rb +++ b/spec/mobility_spec.rb @@ -223,14 +223,4 @@ def perform_with_locale(locale) }.to yield_with_args(described_class.config) end end - - # TODO: remove default_fallbacks in v1.0 - %w[accessor_method query_method default_fallbacks new_fallbacks default_accessor_locales].each do |delegated_method| - describe ".#{delegated_method}" do - it "delegates to config" do - expect(described_class.config).to receive(delegated_method).and_return("foo") - expect(described_class.send(delegated_method)).to eq("foo") - end - end - end end