abstract class Granite::Base
- Granite::Base
- Reference
- Object
Overview
Granite::Base is the base class for your model objects.
Included Modules
- Granite::Associations
- Granite::Callbacks
- Granite::Columns
- Granite::ConnectionManagement
- Granite::Migrator
- Granite::Querying
- Granite::Select
- Granite::Tables
- Granite::Transactions
- Granite::ValidationHelpers
- Granite::Validators
Extended Modules
- Granite::Columns::ClassMethods
- Granite::Integrators
- Granite::Migrator::ClassMethods
- Granite::Query::BuilderMethods
- Granite::Querying::ClassMethods
- Granite::Select
- Granite::Tables::ClassMethods
- Granite::Transactions::ClassMethods
Defined in:
granite/base.crClass Method Summary
- .adapter
-
.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.
-
.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.
- .current_adapter : Granite::Adapter::Base | Nil
- .current_adapter=(current_adapter : Granite::Adapter::Base | Nil)
- .last_write_time
- .reader_adapter : Granite::Adapter::Base | Nil
- .reader_adapter=(reader_adapter : Granite::Adapter::Base | Nil)
- .schedule_adapter_switch
- .switch_to_reader_adapter
- .switch_to_writer_adapter
- .time_since_last_write
-
.update_last_write_time
This is done this way because callbacks don't work on class mthods
- .writer_adapter : Granite::Adapter::Base | Nil
- .writer_adapter=(writer_adapter : Granite::Adapter::Base | Nil)
Instance Method Summary
- #schedule_adapter_switch
- #switch_to_reader_adapter
- #switch_to_writer_adapter
- #time_since_last_write
- #update_last_write_time
Macros inherited from module Granite::ConnectionManagement
connection(name)
connection
Instance methods inherited from module Granite::Querying
reload
reload
Macros inherited from module Granite::Select
select_statement(text)
select_statement
Macros inherited from module Granite::ValidationHelpers
validate_exclusion(field, excluded_values)
validate_exclusion,
validate_greater_than(field, amount, or_equal_to = false)
validate_greater_than,
validate_is_blank(field)
validate_is_blank,
validate_is_nil(field)
validate_is_nil,
validate_is_valid_choice(field, choices)
validate_is_valid_choice,
validate_less_than(field, amount, or_equal_to = false)
validate_less_than,
validate_max_length(field, length)
validate_max_length,
validate_min_length(field, length)
validate_min_length,
validate_not_blank(field)
validate_not_blank,
validate_not_nil(field)
validate_not_nil,
validate_uniqueness(field)
validate_uniqueness
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!
Macros inherited from module Granite::Tables
table(name)
table
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
Macros inherited from module Granite::Columns
column(decl, **options)
column,
timestamps
timestamps
Instance methods inherited from module Granite::Callbacks
abort!(message = "Aborted at #{@_current_callback}.")
abort!
Macros inherited from module Granite::Callbacks
__after_create
__after_create,
__after_destroy
__after_destroy,
__after_save
__after_save,
__after_update
__after_update,
__before_create
__before_create,
__before_destroy
__before_destroy,
__before_save
__before_save,
__before_update
__before_update,
after_create(*callbacks, &block)
after_create,
after_destroy(*callbacks, &block)
after_destroy,
after_save(*callbacks, &block)
after_save,
after_update(*callbacks, &block)
after_update,
before_create(*callbacks, &block)
before_create,
before_destroy(*callbacks, &block)
before_destroy,
before_save(*callbacks, &block)
before_save,
before_update(*callbacks, &block)
before_update
Macros inherited from module Granite::Associations
belongs_to(model, **options)
belongs_to,
has_many(model, **options)
has_many,
has_one(model, **options)
has_one
Class Method Detail
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.
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.
This is done this way because callbacks don't work on class mthods