lib/sequel/model.rb in sequel-4.44.0 vs lib/sequel/model.rb in sequel-4.45.0
- old
+ new
@@ -3,15 +3,17 @@
require 'sequel/core'
module Sequel
# Delegate to Sequel::Model, only for backwards compatibility.
def self.cache_anonymous_models
+ Sequel::Deprecation.deprecate("Sequel.cache_anonymous_models", "Use Sequel::Model.cache_anonymous_models")
Model.cache_anonymous_models
end
# Delegate to Sequel::Model, only for backwards compatibility.
def self.cache_anonymous_models=(v)
+ Sequel::Deprecation.deprecate("Sequel.cache_anonymous_models=", "Use Sequel::Model.cache_anonymous_models=")
Model.cache_anonymous_models = v
end
# <tt>Sequel::Model</tt> is an object relational mapper built on top of Sequel core. Each
# model class is backed by a dataset instance, and many dataset methods can be
@@ -27,17 +29,10 @@
# You can set the +SEQUEL_NO_ASSOCIATIONS+ constant or environment variable to
# make Sequel not load the associations plugin by default.
class Model
OPTS = Sequel::OPTS
- # Map that stores model classes created with <tt>Sequel::Model()</tt>, to allow the reopening
- # of classes when dealing with code reloading.
- ANONYMOUS_MODEL_CLASSES = @Model_cache = {}
-
- # Mutex protecting access to ANONYMOUS_MODEL_CLASSES
- ANONYMOUS_MODEL_CLASSES_MUTEX = @Model_mutex = Mutex.new
-
# Class methods added to model that call the method of the same name on the dataset
DATASET_METHODS = (Dataset::ACTION_METHODS + Dataset::QUERY_METHODS + [:each_server, :where_all, :where_each, :where_single_value]) -
[:and, :or, :[], :columns, :columns!, :delete, :update, :add_graph_aliases, :first, :first!]
# Boolean settings that can be modified at the global, class, or instance level.
@@ -49,12 +44,12 @@
# so later hooks are called before earlier hooks.
BEFORE_HOOKS = [:before_create, :before_update, :before_save, :before_destroy, :before_validation]
# Hooks that are called after an action. When overriding these, it is recommended to call
# +super+ on the first line of your method, so later hooks are called after earlier hooks.
- AFTER_HOOKS = [:after_create, :after_update, :after_save, :after_destroy,
- :after_validation, :after_commit, :after_rollback, :after_destroy_commit, :after_destroy_rollback]
+ AFTER_HOOKS = [:after_create, :after_update, :after_save, :after_destroy, :after_validation,
+ :after_commit, :after_rollback, :after_destroy_commit, :after_destroy_rollback] # SEQUEL5: Remove commit/rollback hooks
# Hooks that are called around an action. If overridden, these methods must call super
# exactly once if the behavior they wrap is desired. The can be used to rescue exceptions
# raised by the code they wrap or ensure that some behavior is executed no matter what.
AROUND_HOOKS = [:around_create, :around_update, :around_save, :around_destroy, :around_validation]
@@ -76,11 +71,11 @@
:@typecast_empty_string_to_nil=>nil, :@typecast_on_assignment=>nil,
:@raise_on_typecast_failure=>nil, :@plugins=>:dup, :@setter_methods=>nil,
:@use_after_commit_rollback=>nil, :@fast_pk_lookup_sql=>nil,
:@fast_instance_delete_sql=>nil, :@finders=>:dup, :@finder_loaders=>:dup,
:@db=>nil, :@default_set_fields_options=>:dup, :@require_valid_table=>nil,
- :@cache_anonymous_models=>nil, :@Model_mutex=>nil}
+ :@cache_anonymous_models=>nil, :@dataset_module_class=>nil}
# Regular expression that determines if a method name is normal in the sense that
# it could be used literally in ruby code without using send. Used to
# avoid problems when using eval with a string to define methods.
NORMAL_METHOD_NAME_REGEXP = /\A[A-Za-z_][A-Za-z0-9_]*\z/
@@ -127,7 +122,25 @@
# The setter methods (methods ending with =) that are never allowed
# to be called automatically via +set+/+update+/+new+/etc..
RESTRICTED_SETTER_METHODS = instance_methods.map(&:to_s).grep(SETTER_METHOD_REGEXP)
def_Model(::Sequel)
+
+ # SEQUEL5: Remove
+ class DeprecatedColumnsUpdated # :nodoc:
+ def initialize(columns_updated)
+ @columns_updated = columns_updated
+ end
+
+ def method_missing(*args, &block)
+ Sequel::Deprecation.deprecate("Accessing @columns_updated directly", "Use the columns_updated plugin and switch to the columns_updated method")
+ @columns_updated.send(*args, &block)
+ end
+ end
+
+ ANONYMOUS_MODEL_CLASSES = @Model_cache # :nodoc:
+ Sequel::Deprecation.deprecate_constant(self, :ANONYMOUS_MODEL_CLASSES)
+
+ ANONYMOUS_MODEL_CLASSES_MUTEX = Mutex.new # :nodoc:
+ Sequel::Deprecation.deprecate_constant(self, :ANONYMOUS_MODEL_CLASSES_MUTEX)
end
end