abstract class Granite::Base

Overview

Granite::Base is the base class for your model objects.

Included Modules

Extended Modules

Defined in:

granite/base.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from module Granite::Validators

errors errors, valid? valid?

Instance methods inherited from module Granite::Transactions

destroy destroy, destroy! destroy!, save(*, validate : Bool = true, skip_timestamps : Bool = false) save, save!(*, validate : Bool = true, skip_timestamps : Bool = false) save!, set_timestamps(*, to time = Time.local(Granite.settings.default_timezone), mode = :create) set_timestamps, touch(*fields) : Bool touch, update(args, skip_timestamps : Bool = false)
update(**args)
update
, update!(args, skip_timestamps : Bool = false)
update!(**args)
update!

Instance methods inherited from module Granite::Columns

content_values : Array(Granite::Columns::Type) content_values, from_rs(result : DB::ResultSet) : Nil from_rs, primary_key_value primary_key_value, read_attribute(attribute_name : Symbol | String) : Type read_attribute, set_attributes(hash : Hash(String | Symbol, T)) : self forall T set_attributes, to_h to_h

Instance methods inherited from module Granite::Callbacks

abort!(message = "Aborted at #{@_current_callback}.") abort!

Class Method Detail

def self.adapter #

[View source]
def self.connection_switch_wait_period : Int32 #

Default value for the time a model waits before using a reader database connection for read operations all models use this value. Change it to change it in all Granite::Base models.


def self.connection_switch_wait_period=(connection_switch_wait_period : Int32) #

Default value for the time a model waits before using a reader database connection for read operations all models use this value. Change it to change it in all Granite::Base models.


def self.current_adapter : Granite::Adapter::Base | Nil #

def self.current_adapter=(current_adapter : Granite::Adapter::Base | Nil) #

def self.last_write_time #

[View source]
def self.reader_adapter : Granite::Adapter::Base | Nil #

def self.reader_adapter=(reader_adapter : Granite::Adapter::Base | Nil) #

def self.schedule_adapter_switch #

[View source]
def self.switch_to_reader_adapter #

[View source]
def self.switch_to_writer_adapter #

[View source]
def self.time_since_last_write #

[View source]
def self.update_last_write_time #

This is done this way because callbacks don't work on class mthods


[View source]
def self.writer_adapter : Granite::Adapter::Base | Nil #

def self.writer_adapter=(writer_adapter : Granite::Adapter::Base | Nil) #

Instance Method Detail

def schedule_adapter_switch #

[View source]
def switch_to_reader_adapter #

[View source]
def switch_to_writer_adapter #

[View source]
def time_since_last_write #

[View source]
def update_last_write_time #

[View source]