module CQL::ActiveRecord::Attributes

Defined in:

active_record/attributes.cr

Instance Method Summary

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=.


[View source]
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"

[View source]
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.


[View source]