module
CQL::ActiveRecord::Attributes
Defined in:
active_record/attributes.crInstance Method Summary
-
#attributes(attrs : Hash(Symbol, DB::Any))
Set the record's attributes from a hash - @param attrs [Hash(Symbol, DB::Any)] The attributes to set - @return [Nil]
-
#attributes
The record's attributes, keyed by column name - @return [Hash(Symbol, DB::Any)] The attributes
-
#attributes(**attrs)
Set the record's attributes from a hash - @param attrs [Hash(Symbol, DB::Any)] The attributes to set - @return [Nil]
Instance Method Detail
def attributes(attrs : Hash(Symbol, DB::Any))
#
Set the record's attributes from a hash
- @param attrs [Hash(Symbol, DB::Any)] The attributes to set
- @return [Nil]
Example Setting the record's attributes
user.attributes({:name => "Alice", :email => "alice@example.com"} of Symbol => DB::Any)
The primary key is not assigned: mass assignment must not re-point a record at another row.
Set it with id=.
def attributes
#
The record's attributes, keyed by column name
- @return [Hash(Symbol, DB::Any)] The attributes
Example Fetching the record's attributes
user.attributes[:name] # => "Alice"
def attributes(**attrs)
#
Set the record's attributes from a hash
- @param attrs [Hash(Symbol, DB::Any)] The attributes to set
- @return [Nil]
Example Setting the record's attributes
user.attributes(name: "Alice", email: "alice@example.com")
Like #attributes(Hash), this never assigns the primary key.