class Sequel::Model
Sequel::Model
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 called directly on the
class. Model datasets return rows as model
instances, which have fairly standard ORM instance behavior.
Sequel::Model
is built completely out of plugins. Plugins can override any class, instance, or
dataset method defined by a previous plugin and call super to get the
default behavior. By default, Sequel::Model
loads two
plugins, Sequel::Model
(which is itself a plugin) for the base
support, and Sequel::Model::Associations
for the associations
support.
You can set the SEQUEL_NO_ASSOCIATIONS
constant or environment
variable to make Sequel not load the
associations plugin by default.
Constants
- AFTER_HOOKS
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.- AROUND_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.
- BEFORE_HOOKS
Hooks that are called before an action. Can return false to not do the action. When overriding these, it is recommended to call
super
as the last line of your method, so later hooks are called before earlier hooks.- BOOLEAN_SETTINGS
Boolean settings that can be modified at the global, class, or instance level.
- DATASET_METHODS
Class methods added to model that call the method of the same name on the dataset
- HOOKS
Empty instance methods to create that the user can override to get hook/callback behavior. Just like any other method defined by Sequel, if you override one of these, you should call
super
to get the default behavior (while empty by default, they can also be defined by plugins). See the “Model Hooks” guide for more detail on hooks.- INHERITED_INSTANCE_VARIABLES
Class instance variables that are inherited in subclasses. If the value is
:dup
, dup is called on the superclass's instance variable when creating the instance variable in the subclass. If the value isnil
, the superclass's instance variable is used directly in the subclass.- NORMAL_METHOD_NAME_REGEXP
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.
- OPTS
- RESTRICTED_SETTER_METHODS
The setter methods (methods ending with =) that are never allowed to be called automatically via
set
/update
/new
/etc..- SETTER_METHOD_REGEXP
Regular expression that determines if the method is a valid setter name (i.e. it ends with =).