class

RethinkORM::Lock

Inherits 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

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

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, }

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

Constructors

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

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

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

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

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

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

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)

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

Source
new(pull : JSON::PullParser)

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

Source
new(rs : DB::ResultSet)

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

Source
new(key : String, expire : Time::Span | Nil = nil, timeout : Time::Span | Nil = nil, instance_token : String = Lock.new_instance_token)

Reset instance token if it's loaded and expired?

Source
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, id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new)

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

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

Initialize RethinkORM::Lock from HTTP::Params.

Class methods

attributes

Returns all attribute keys.

expired

Returns all expired locks

Source
find(key)

Hash a key

Source
from_rs(rs : DB::ResultSet)

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

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(key : String | Missing = Missing, instance_token : String | Missing = Missing, expires_at : Time | Missing = Missing, id : String | Nil | 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)

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.

expire

Seconds before the lock expires

Source
expire=(expire : Time::Span)

Seconds before the lock expires

Source
expires_at

expires_at getter

expires_at=(value : Time)

expires_at setter

expires_at?

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.

expires_at_assigned?

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

expires_at_change

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

expires_at_changed?

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

expires_at_default

expires_at's default value

Source
expires_at_present?
expires_at_removed?

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

expires_at_was

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

expires_at_will_change!

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

id

id getter

id=(value : String | Nil)

id setter

instance_token

instance_token getter

instance_token=(value : String)

instance_token setter

instance_token?

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.

instance_token_assigned?

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

instance_token_change

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

instance_token_changed?

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

instance_token_default

instance_token's default value

Source
instance_token_present?
instance_token_removed?

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

instance_token_was

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

instance_token_will_change!

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

key

key getter

key=(value : String)

Setters key setter

key?

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.

key_assigned?

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

key_change

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

key_changed?

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

key_default

key's default value

Source
key_present?

Key is not an index, PKs are 127 chars.

key_removed?

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

key_was

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

key_will_change!

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

lock(expire : Time::Span = self.expire, timeout : Time::Span = self.timeout)
Source
locked?
Source
persistent_attributes

Returns a Hash of all attributes that can be persisted.

refresh(expire : Time::Span | Nil = nil)
Source
restore_attributes

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

synchronize
Source
table_name

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

timeout

Lock acquisition timeout

Source
timeout=(timeout : Time::Span)

Lock acquisition timeout

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

Validate that all non-nillable fields have values.

Nested types