class RethinkORM::Lock::Reentrant

Defined in:

rethinkdb-orm/lock/reentrant.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}

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class RethinkORM::Lock

after_create after_create, after_destroy after_destroy, after_initialize(trusted : Bool) after_initialize, after_save after_save, after_update after_update, apply_defaults apply_defaults, assign_attributes(key : String | Missing = Missing, instance_token : String | Missing = Missing, expires_at : Time | Missing = Missing, id : String? | Missing = Missing)
assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
assign_attributes
, assign_attributes_from_json(json, root : String)
assign_attributes_from_json(json)
assign_attributes_from_json
, assign_attributes_from_trusted_json(json, root : String)
assign_attributes_from_trusted_json(json)
assign_attributes_from_trusted_json
, assign_attributes_from_trusted_yaml(yaml) assign_attributes_from_trusted_yaml, assign_attributes_from_yaml(yaml) assign_attributes_from_yaml, attributes attributes, attributes_tuple attributes_tuple, before_create before_create, before_destroy before_destroy, before_save before_save, before_update before_update, changed? changed?, changed_attributes changed_attributes, changed_json(io : IO) : Nil
changed_json : String
changed_json
, changed_yaml(io : IO) : Nil
changed_yaml : String
changed_yaml
, clear_changes_information clear_changes_information, expire : Time::Span expire, expire=(expire : Time::Span) expire=, expires_at : Time expires_at, expires_at=(value : Time) expires_at=, expires_at? : Time? expires_at?, expires_at_change : Tuple(Time?, Time?)? expires_at_change, expires_at_changed? : Bool expires_at_changed?, expires_at_default : Time expires_at_default, expires_at_present? : Bool expires_at_present?, expires_at_was : Time? expires_at_was, expires_at_will_change! : Nil expires_at_will_change!, id : String? id, id=(value : String?) id=, instance_token : String instance_token, instance_token=(value : String) instance_token=, instance_token? : String? instance_token?, instance_token_change : Tuple(String?, String?)? instance_token_change, instance_token_changed? : Bool instance_token_changed?, instance_token_default : String instance_token_default, instance_token_present? : Bool instance_token_present?, instance_token_was : String? instance_token_was, instance_token_will_change! : Nil instance_token_will_change!, key : String key, key=(value : String) key=, key? : String? key?, key_change : Tuple(String?, String?)? key_change, key_changed? : Bool key_changed?, key_default : String key_default, key_present? : Bool key_present?, key_was : String? key_was, key_will_change! : Nil key_will_change!, lock(expire : Time::Span = self.expire, timeout : Time::Span = self.timeout) lock, locked? : Bool locked?, persistent_attributes persistent_attributes, refresh(expire : Time::Span? = nil) refresh, restore_attributes restore_attributes, run_create_callbacks(&) run_create_callbacks, run_destroy_callbacks(&) run_destroy_callbacks, run_save_callbacks(&) run_save_callbacks, run_update_callbacks(&) run_update_callbacks, synchronize(**options, &) synchronize, table_name table_name, timeout : Time::Span timeout, timeout=(timeout : Time::Span) timeout=, try_lock(expire : Time::Span = self.expire) try_lock, unlock unlock, validate_nilability validate_nilability

Constructor methods inherited from class RethinkORM::Lock

from_json(string_or_io : String | IO, trusted : Bool = false) : self
from_json(string_or_io : String | IO, root : String, trusted : Bool = false) : self
from_json
, from_trusted_json(string_or_io : String | IO, root : String) : self
from_trusted_json(string_or_io : String | IO) : self
from_trusted_json
, from_trusted_yaml(string_or_io : String | IO) : self from_trusted_yaml, from_yaml(string_or_io : String | IO, trusted : Bool = false) : self from_yaml, new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
new(pull : JSON::PullParser)
new(key : String, expire : Time::Span? = nil, timeout : Time::Span? = nil, instance_token : String = Lock.new_instance_token)
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? | ActiveModel::Model::None = ::ActiveModel::Model::None.new)
new(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
new

Class methods inherited from class RethinkORM::Lock

attributes : Array(Symbol) attributes, expired expired, find(key) find, table_name table_name

Instance methods inherited from class RethinkORM::Base

==(other : self) ==, apply_defaults apply_defaults, assign_attributes(id : String? | Missing = Missing)
assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
assign_attributes
, attributes attributes, attributes_tuple attributes_tuple, id : String? id, id=(id : String?) id=, id_change : Tuple(String??, String??)? id_change, id_changed? : Bool id_changed?, id_default : String? id_default, id_present? : Bool id_present?, id_was : String | Nil | Nil id_was, id_will_change! : Nil id_will_change!, persistent_attributes persistent_attributes, uuid_generator=(generator : Class) uuid_generator=

Constructor methods inherited from class RethinkORM::Base

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
new(pull : JSON::PullParser)
new

Class methods inherited from class RethinkORM::Base

all(**options) all, attributes : Array(Symbol) attributes, changes(id : String? = 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, **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

_new_flag _new_flag, _new_flag=(_new_flag) _new_flag=, delete delete, destroy destroy, destroyed=(destroyed : Bool) destroyed=, destroyed? : Bool 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_json(string_or_io : String | IO, trusted : Bool = false) : self #

def 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">

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

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.from_yaml(string_or_io : String | IO, trusted : Bool = false) : self #

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
def self.new(pull : JSON::PullParser) #

[View source]
def self.new(key : String, expire : Time::Span? = nil, timeout : Time::Span? = nil, instance_token : String = Lock.new_instance_token) #

[View source]
def self.new(lock_count : Int32 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : String? | 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) #

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

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


Class Method Detail

def self.attributes : Array(Symbol) #

Returns all attribute keys.


def self.table_name #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


Instance Method Detail

def after_create #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def after_destroy #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def after_initialize(trusted : Bool) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def after_save #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def after_update #
Description copied from class RethinkORM::Lock

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(lock_count : Int32 | Missing = Missing, id : String? | 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, root : String) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def assign_attributes_from_json(json) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def assign_attributes_from_trusted_json(json, root : String) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


def assign_attributes_from_trusted_json(json) #

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


def assign_attributes_from_trusted_yaml(yaml) #
Description copied from class RethinkORM::Lock

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 #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def before_destroy #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def before_save #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def before_update #
Description copied from class RethinkORM::Lock

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 expires_at : Time #

#expires_at getter


def expires_at=(value : Time) #

#expires_at setter


def id : String? #

#id getter


def id=(value : String?) #

#id setter


def instance_token : String #

def instance_token=(value : String) #

def key : String #

#key getter


def key=(value : String) #

#key setter


def lock_count : Int32 #

#lock_count getter


def lock_count=(value : Int32) #

Setters #lock_count setter


def lock_count? : Int32? #

def lock_count_change : Tuple(Int32?, Int32?)? #

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


def lock_count_changed? : Bool #

def lock_count_default : Int32 #

#lock_count's default value


[View source]
def lock_count_present? : Bool #

def lock_count_was : Int32? #

def lock_count_will_change! : Nil #

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


def persistent_attributes #

Returns a Hash of all attributes that can be persisted.


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(&) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def run_save_callbacks(&) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def run_update_callbacks(&) #
Description copied from class RethinkORM::Lock

DB locks for RethinkDB

TODO Conform to the NoBrainer locking interface.


[View source]
def table_name #
Description copied from class RethinkORM::Lock

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.