abstract class Jennifer::View::Base

Overview

Base class for a database view).

The functionality provided by view is close to the one of Model::Base but has next limitations:

class FemaleContact < BaseView
  mapping({
    id:   Primary32,
    name: String,
    }, false)
  end
end

Included Modules

Direct Known Subclasses

Defined in:

jennifer/view/base.cr

Class Method Summary

Instance Method Summary

Macro Summary

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.build(values : Hash | NamedTuple, new_record : Bool) #

Alias for .new.


[View source]
def self.build(pull : DB::ResultSet) #

Alias for .new.


[View source]
def self.i18n_scope #

[View source]
def self.relation(name) #

[View source]
def self.view_name(value : String) #

Sets view name.

An alias for .table_name(value : String).


[View source]
def self.view_name #

Returns view name.

An alias for .table_name.


[View source]
def self.views #

Returns array of all registered views or [] of Jennifer::View::Base.class if nothing.


[View source]

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">

[View source]

Macro Detail

macro after_initialize(*names) #

Allows registering after_initialize callbacks.


[View source]