abstract class Jennifer::View::Base
- Jennifer::View::Base
- Jennifer::Model::Resource
- Reference
- Object
Overview
Base class for a database view).
The functionality provided by view is close to the one of Model::Base
but has next limitations:
- supports only
after_initialize
callback - doesn't support any relations
- has no persistence mechanism
- doesn't support virtual attributes
class FemaleContact < BaseView
mapping({
id: Primary32,
name: String,
}, false)
end
end
Included Modules
Direct Known Subclasses
Defined in:
jennifer/view/base.crClass Method Summary
-
.build(values : Hash | NamedTuple, new_record : Bool)
Alias for
.new
. -
.build(pull : DB::ResultSet)
Alias for
.new
. - .i18n_scope
- .relation(name)
-
.view_name(value : String)
Sets view name.
-
.view_name
Returns view name.
-
.views
Returns array of all registered views or
[] of Jennifer::View::Base.class
if nothing.
Instance Method Summary
-
#reload
Reloads the record from the database.
Macro Summary
-
after_initialize(*names)
Allows registering
after_initialize
callbacks.
Instance methods inherited from module Jennifer::Model::Mapping
attribute_metadata(name : String | Symbol)
attribute_metadata
Instance methods inherited from class Jennifer::Model::Resource
append_relation(name : String, hash)
append_relation,
attribute(name : String | Symbol, raise_exception : Bool = true)
attribute,
get_relation(name : String)
get_relation,
inspect(io) : Nil
inspect,
primary
primary,
set_inverse_of(name : String, object)
set_inverse_of,
to_h
to_h,
to_json(only : Array(String)? = nil, except : Array(String)? = nil)to_json(only : Array(String)? = nil, except : Array(String)? = nil, &)
to_json(json : JSON::Builder)
to_json(json : JSON::Builder, only : Array(String)? = nil, except : Array(String)? = nil, &) to_json, to_str_h to_str_h
Class methods inherited from class Jennifer::Model::Resource
adapter
adapter,
all
all,
build(values : Hash(Symbol, Jennifer::DBAny) | NamedTuple)build(values : Hash(String, Jennifer::DBAny))
build(**values) build, c(name : String | Symbol, relation)
c(name : String | Symbol) c, context context, read_adapter read_adapter, relation(name) relation, star star, table_name(value : String | Symbol)
table_name : String table_name, transaction(&) transaction, where(&)
where(conditions : Hash(Symbol, _)) where, write_adapter write_adapter
Instance methods inherited from module Jennifer::Model::RelationDefinition
append_relation(name : String, hash)
append_relation,
get_relation(name : String)
get_relation,
relation_retrieved(name : String)
relation_retrieved,
set_inverse_of(name : String, object)
set_inverse_of
Instance methods inherited from module Jennifer::Model::Translation
class_name : String
class_name,
human_attribute_name(attribute : String | Symbol)
human_attribute_name,
lookup_ancestors(&)
lookup_ancestors
Class Method Detail
def self.views
#
Returns array of all registered views or [] of Jennifer::View::Base.class
if nothing.
Instance Method Detail
def reload
#
Reloads the record from the database.
This method finds record by its primary key and modifies the receiver in-place.
user = AdminUser.first!
user.name = "John"
user.reload # => #<AdminUser id: 1, name: "Will">