class RethinkORM::Lock

Overview

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.

Extended Modules

Direct Known Subclasses

Defined in:

rethinkdb-orm/lock.cr

Constant Summary

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

Class Method Summary

Instance Method Summary

Instance methods inherited from class RethinkORM::Base

==(other : self) ==, apply_defaults apply_defaults, assign_attributes(id : String | Nil | Missing = Missing)
assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
assign_attributes
, attributes attributes, attributes_tuple attributes_tuple, id_default : String | Nil id_default, persistent_attributes persistent_attributes, uuid_generator=(generator : Class) uuid_generator=

Class methods inherited from class RethinkORM::Base

all(**options) all, attributes : Array(Symbol) attributes, changes(id : String | Nil = nil, **options)
changes(**options, & : RethinkDB::Table -> HasChanges)
changes
, clear clear, collection_query(**options, &) collection_query, count
count(**attrs)
count(**attrs, &predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
count
, create(**attributes) create, create!(**attributes) create!, exists?(id : String, **options) exists?, find(id : String, **options) find, find!(id : String, **options) find!, find_all(ids : Array | Tuple, **options) find_all, find_by(**attribute)
find_by(**attribute, &predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
find_by
, get_all(values : Array | Tuple, **options) get_all, has_index?(field) has_index?, raw_changes(id : String | Nil = nil, **options)
raw_changes(**options, & : RethinkDB::Table -> HasChanges)
raw_changes
, raw_query(**options, &) raw_query, table_query(**options, &) table_query, where(&predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
where(**attrs, &predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
where(attrs : Hash, **options)
where(**attrs)
where

Instance methods inherited from module RethinkORM::Persistence

delete delete, destroy destroy, destroyed destroyed, destroyed=(destroyed) destroyed=, destroyed? destroyed?, new_record? new_record?, persisted? persisted?, reload! reload!, save(**options) save, save!(**options) save!, update(**attributes) update, update!(**attributes) update!, update_fields(**attributes) update_fields

Instance methods inherited from module RethinkORM::Associations

reset_associations reset_associations

Constructor Detail

def self.from_trusted_json(string_or_io : String | IO) : self #

Serialize from a trusted JSON source


def self.from_trusted_yaml(string_or_io : String | IO) : self #

Serialize from a trusted YAML source


def self.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?


[View source]
def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def self.new(id : String | Nil | Nil = nil, key : String | Nil = nil, instance_token : String | Nil = nil, expires_at : Time | Nil = nil) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def self.new(params : HTTP::Params | Hash(String, String) | Tuple(String, String)) #

Initialize RethinkORM::Lock from HTTP::Params.


Class Method Detail

def self.attributes : Array(Symbol) #

Returns all attribute keys.


def self.expired #

Returns all expired locks


[View source]
def self.find(key) #

Hash a key


[View source]
def self.table_name #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


Instance Method Detail

def after_create #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def after_destroy #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def after_save #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def after_update #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def apply_defaults #

Generate code to apply default values


def assign_attributes(id : String | Nil | Missing = Missing, key : String | Missing = Missing, instance_token : String | Missing = Missing, expires_at : Time | Missing = Missing) #

Assign to multiple attributes.


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

Assign to mulitple attributes via HTTP::Params.


def assign_attributes_from_json(json) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def assign_attributes_from_trusted_json(json) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def assign_attributes_from_trusted_yaml(yaml) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def assign_attributes_from_yaml(yaml) #

Uses the YAML parser as JSON is valid YAML


def attributes #

Returns a Hash of all attribute values


def attributes_tuple #

Returns a NamedTuple of all attribute values.


def before_create #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def before_destroy #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def before_save #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def before_update #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def changed? #

Check if any attributes have changed.


def changed_attributes #

Returns a Hash with all changed attributes.


def changed_json(io : IO) : Nil #

Serialize the set of changed attributes to JSON.


def changed_json : String #

Serialize the set of changed attributes to JSON.


def changed_yaml(io : IO) : Nil #

Serialize the set of changed attributes to YAML.


def changed_yaml : String #

Serialize the set of changed attributes to YAML.


def clear_changes_information #

Reset changes for all attributes.


def expire : Time::Span #

Seconds before the lock expires


[View source]
def expire=(expire : Time::Span) #

Seconds before the lock expires


[View source]
def expires_at : Time #

#expires_at getter


def expires_at=(value : Time) #

#expires_at setter


def expires_at_change #

Returns { expires_at_was, expires_at } if #expires_at has changed.


def expires_at_changed? #

Check if #expires_at is in the set of changed attributes.


def expires_at_default : Time #

#expires_at's default value


[View source]
def expires_at_was : Time? #

Returns the previous value of #expires_at.


def expires_at_will_change! #

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


def id : String | Nil #

#id getter


def id=(value : String | Nil) #

Override the map json #id setter


def id_change #

Returns { id_was, id } if #id has changed.


def id_changed? #

Check if #id is in the set of changed attributes.


def id_default : String | Nil #

#id's default value


[View source]
def id_was : String? #

Returns the previous value of #id.


def id_will_change! #

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


def instance_token : String #

def instance_token=(value : String) #

def instance_token_change #

Returns { instance_token_was, instance_token } if #instance_token has changed.


def instance_token_changed? #

Check if #instance_token is in the set of changed attributes.


def instance_token_default : String #

#instance_token's default value


[View source]
def instance_token_was : String? #

Returns the previous value of #instance_token.


def instance_token_will_change! #

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


def key : String #

#key getter


def key=(value : String) #

#key setter


def key_change #

Returns { key_was, key } if #key has changed.


def key_changed? #

Check if #key is in the set of changed attributes.


def key_default : String #

#key's default value


[View source]
def key_was : String? #

Returns the previous value of #key.


def key_will_change! #

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


def lock(expire : Time::Span = self.expire, timeout : Time::Span = self.timeout) #

[View source]
def locked? : Bool #

[View source]
def persistent_attributes #

Returns a Hash of all attributes that can be persisted.


def refresh(expire : Time::Span | Nil = nil) #

[View source]
def restore_attributes #

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


def run_create_callbacks(&) #

Wrap a block with callbacks for the appropriate crud operation


[View source]
def run_destroy_callbacks(&) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def run_save_callbacks(&) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def run_update_callbacks(&) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def synchronize(**options, &) #

[View source]
def table_name #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def timeout : Time::Span #

Lock acquisition timeout


[View source]
def timeout=(timeout : Time::Span) #

Lock acquisition timeout


[View source]
def to_json(json : JSON::Builder) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def to_yaml(__temp_96 : YAML::Nodes::Builder) #

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def try_lock(expire : Time::Span = self.expire) #

[View source]
def unlock #

[View source]
def validate_nilability #

Validate that all non-nillable fields have values.