class RethinkORM::Lock
- RethinkORM::Lock
- RethinkORM::Base
- ActiveModel::Model
- Reference
- Object
Overview
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Extended Modules
Direct Known Subclasses
Defined in:
rethinkdb-orm/lock.crConstant 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
-
.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. -
.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.
-
.new(pull : JSON::PullParser)
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
.new(rs : DB::ResultSet)
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
.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?
-
.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 Method Summary
-
.attributes : Array(Symbol)
Returns all attribute keys.
-
.expired
Returns all expired locks
-
.find(key)
Hash a key
-
.from_rs(rs : DB::ResultSet)
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
.table_name
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
Instance Method Summary
-
#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 mulitple 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 : String
Serialize the set of changed attributes to JSON.
-
#changed_yaml(io : IO) : Nil
Serialize the set of changed attributes to YAML.
-
#changed_yaml : String
Serialize the set of changed attributes to YAML.
-
#clear_changes_information
Reset changes for all attributes.
- #expire : Time::Span
- #expire=(expire : Time::Span)
-
#expires_at : Time
#expires_at
getter -
#expires_at=(value : Time)
#expires_at
setter - #expires_at? : Time | Nil
-
#expires_at_assigned? : Bool
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#expires_at_change : Tuple(Time | Nil, Time | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
-
#expires_at_changed? : Bool
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#expires_at_default : Time
#expires_at
's default value - #expires_at_present? : Bool
-
#expires_at_was : Time | Nil
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#expires_at_will_change! : Nil
Include
#expires_at
in the set of changed attributes, whether it has changed or not. -
#id : String | Nil
#id
getter -
#id=(value : String | Nil)
#id
setter -
#instance_token : String
#instance_token
getter -
#instance_token=(value : String)
#instance_token
setter - #instance_token? : String | Nil
-
#instance_token_assigned? : Bool
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#instance_token_change : Tuple(String | Nil, String | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
-
#instance_token_changed? : Bool
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#instance_token_default : String
#instance_token
's default value - #instance_token_present? : Bool
-
#instance_token_was : String | Nil
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#instance_token_will_change! : Nil
Include
#instance_token
in the set of changed attributes, whether it has changed or not. -
#key : String
#key
getter -
#key=(value : String)
Setters
#key
setter -
#key? : String | Nil
Key is not an index, PKs are 127 chars.
-
#key_assigned? : Bool
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#key_change : Tuple(String | Nil, String | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
-
#key_changed? : Bool
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#key_default : String
#key
's default value -
#key_present? : Bool
Key is not an index, PKs are 127 chars.
-
#key_was : String | Nil
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#key_will_change! : Nil
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)
- #locked? : Bool
-
#persistent_attributes
Returns a
Hash
of all attributes that can be persisted. - #refresh(expire : Time::Span | Nil = nil)
-
#restore_attributes
Reset each attribute to their previous values and clears all changes.
-
#run_create_callbacks(&)
Wrap a block with callbacks for the appropriate crud operation
-
#run_destroy_callbacks(&)
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#run_save_callbacks(&)
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
-
#run_update_callbacks(&)
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
- #synchronize(**options, &)
-
#table_name
DB locks for RethinkDB TODO: Conform to the NoBrainer locking interface.
- #timeout : Time::Span
- #timeout=(timeout : Time::Span)
- #try_lock(expire : Time::Span = self.expire)
- #unlock
-
#validate_nilability
Validate that all non-nillable fields have values.
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(model : RethinkORM::Base) assign_attributes, attributes attributes, attributes_tuple attributes_tuple, id : String | Nil id, id=(id : String | Nil) id=, id_assigned? : Bool id_assigned?, id_change : Tuple(String | Nil | Nil, String | Nil | Nil) | Nil id_change, id_changed? : Bool id_changed?, id_default : String | Nil 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(rs : DB::ResultSet) new
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, from_rs(rs : DB::ResultSet) from_rs, 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
_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
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">
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Serialize from a trusted JSON source
Serialize from a trusted YAML source
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Reset instance token if it's loaded and expired?
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Initialize RethinkORM::Lock from HTTP::Params
.
Class Method Detail
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Instance Method Detail
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Assign to multiple attributes.
Assign to mulitple attributes via HTTP::Params
.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Assign each field from JSON if field exists in JSON and has changed in model
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Include #expires_at
in the set of changed attributes, whether it has changed or not.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Include #instance_token
in the set of changed attributes, whether it has changed or not.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.
Include #key
in the set of changed attributes, whether it has changed or not.
DB locks for RethinkDB
TODO Conform to the NoBrainer locking interface.