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: "[email protected]"}

[View source]
def attributes #

Define instance-level methods for querying and manipulating data Fetch the record's ID or raise an error if it's nil

  • @return [PrimaryKey] The ID

Example Fetching the record's attributes

user.attributes
-> { id: 1, name: "Alice", email: " [email protected]" }

[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: "[email protected]")

[View source]