RethinkORM::Base
Inherits RethinkORM::Validators / RethinkORM::Table / RethinkORM::Queries / RethinkORM::Persistence / RethinkORM::Index / RethinkORM::Associations / ActiveModel::Callbacks / ActiveModel::Validation / ActiveModel::Model / DB::Mappable / DB::Serializable / YAML::Serializable / JSON::Serializable / Reference / Object
Constants
Constructors
Class methods
Returns all attribute keys.
Changefeed at document (if id passed) or table level
Yields an infinite iterator of model events
Unsafe method until where can accept more generic arguments
Makes 2 LARGE assumptions
- User correctly scopes the query under the right table
- User forms a query that returns a collection of models
Should raise/not compile on malformed query/incorrect return type to create a collection
Establishes a changefeed of models in a RethinkDB table Changefeed at document (id passed) or table level
Unsafe method until where can accept more generic arguments
Makes 2 LARGE assumptions
- User correctly scopes the query under the right table
- User forms a query that returns a collection of models
Should raise/not compile on malformed query/incorrect return type to create a collection
Instance methods
Generate code to apply default values
Assign to multiple attributes.
Assign to multiple attributes via HTTP::Params.
Assign to multiple attributes from a model object
Returns a Hash of all attribute values
Returns a NamedTuple of all attribute values.
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Default primary key
Include id in the set of changed attributes, whether it has changed or not.
Returns a Hash of all attributes that can be persisted.
Wrap a block with callbacks for the appropriate crud operation.
Defined once here rather than once per subclass, and reached through the
before_*/after_* methods rather than by expanding __before_* inline.
These methods yield, and Crystal cannot dispatch a yielding method through
a pointer -- it inlines the body at each call site. Defining them per
subclass therefore meant that a run_*_callbacks call on an abstract
receiver emitted one inlined copy per concrete subclass, each containing a
type-id dispatch chain for every self call in the block. Nesting two of
them (run_update_callbacks { run_save_callbacks { ... } }) made that
quadratic in the number of models.
With a single definition there is one inlined copy, and before_* /
after_* are ordinary non-yielding overrides that share one dispatch
wrapper.