class

RethinkORM::Lock::Reentrant

Inherits RethinkORM::Lock / RethinkORM::Base / 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

CALLBACKS = { before_save: [] of Nil, after_save: [] of Nil, before_create: [] of Nil, after_create: [] of Nil, before_update: [] of Nil, after_update: [] of Nil, before_destroy: [] of Nil, after_destroy: [] of Nil, }

Constructors

from_json(string_or_io : String | IO, trusted : Bool = false) : self
from_json(string_or_io : String | IO, root : String, trusted : Bool = false) : self

Deserializes the given JSON in string_or_io into an instance of self, assuming the JSON consists of an JSON object with key root, and whose value is the value to deserialize. Will not deserialise from fields with mass_assign: false

class User < ActiveModel::Model
  attribute name : String
  attribute google_id : UUID, mass_assign: false
end

User.from_json(%({"main": {"name": "Jason", "google_id": "f6f70bfb-c882-446d-8758-7ce47db39620"}}), root: "main") # => #<User:0x103131b20 @name="Jason">
from_trusted_json(string_or_io : String | IO, root : String) : self
from_trusted_json(string_or_io : String | IO) : self

Serialize from a trusted JSON source

from_trusted_yaml(string_or_io : String | IO) : self

Serialize from a trusted YAML source

from_yaml(string_or_io : String | IO, trusted : Bool = false) : self
new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(pull : JSON::PullParser)
Source
new(rs : DB::ResultSet)
Source
new(key : String, expire : Time::Span | Nil = nil, timeout : Time::Span | Nil = nil, instance_token : String = Lock.new_instance_token)
Source
new(lock_count : Int32 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, key : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, instance_token : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, expires_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new)
new(params : HTTP::Params | Hash(String, String) | Tuple(String, String))

Initialize RethinkORM::Lock::Reentrant from HTTP::Params.

Class methods

attributes

Returns all attribute keys.

from_rs(rs : DB::ResultSet)
Source
table_name

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

Instance methods

after_create

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

after_destroy

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

after_initialize(trusted : Bool)

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

after_save

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

after_update

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

apply_defaults

Generate code to apply default values

assign_attributes(lock_count : Int32 | Missing = Missing, id : String | Nil | Missing = Missing, key : String | Missing = Missing, instance_token : String | Missing = Missing, expires_at : Time | Missing = Missing)

Assign to multiple attributes.

assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))

Assign to multiple attributes via HTTP::Params.

assign_attributes(model : RethinkORM::Lock::Reentrant)

Assign to multiple attributes from a model object

assign_attributes_from_json(json, root : String)

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

assign_attributes_from_json(json)

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

assign_attributes_from_trusted_json(json, root : String)

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

assign_attributes_from_trusted_json(json)

Assign each field from JSON if field exists in JSON and has changed in model

assign_attributes_from_trusted_yaml(yaml)

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

assign_attributes_from_yaml(yaml)

Uses the YAML parser as JSON is valid YAML

attributes

Returns a Hash of all attribute values

attributes_tuple

Returns a NamedTuple of all attribute values.

before_create

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

before_destroy

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

before_save

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

before_update

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

changed?

Check if any attributes have changed.

changed_attributes

Returns a Hash with all changed attributes.

changed_json(io : IO) : Nil

Serialize the set of changed attributes to JSON.

changed_json

Serialize the set of changed attributes to JSON.

changed_yaml(io : IO) : Nil

Serialize the set of changed attributes to YAML.

changed_yaml

Serialize the set of changed attributes to YAML.

clear_changes_information

Reset changes for all attributes.

expires_at

expires_at getter

expires_at=(value : Time)

expires_at setter

id

id getter

id=(value : String | Nil)

id setter

instance_token

instance_token getter

instance_token=(value : String)

instance_token setter

key

key getter

key=(value : String)

key setter

lock_count

lock_count getter

lock_count=(value : Int32)

Setters lock_count setter

lock_count?

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.

lock_count_assigned?
lock_count_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

lock_count_changed?
lock_count_default

lock_count's default value

Source
lock_count_present?
lock_count_removed?
lock_count_was
lock_count_will_change!

Include lock_count in the set of changed attributes, whether it has changed or not.

persistent_attributes

Returns a Hash of all attributes that can be persisted.

restore_attributes

Reset each attribute to their previous values and clears all changes.

table_name

DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.

try_lock(expire : Time::Span = self.expire)
Source
unlock
Source
validate_nilability

Validate that all non-nillable fields have values.