struct Jennifer::Record
- Jennifer::Record
- Struct
- Value
- Object
Overview
General data structure for the raw data retrieved for the DB.
Dynamically generates getters using .method_missing
. If class T
is passed
as an argument - return value is automatically casted to it.
Jennifer::Query["users"].first.name(String)
Defined in:
jennifer/adapter/record.crConstructors
Instance Method Summary
-
#[](name : Symbol | String)
Alias for #attribute.
-
#attribute(name : String | Symbol, type : T.class) : T forall T
Returns casted value of attribute name to the type type.
-
#attribute(name : String)
Returns value by attribute name.
-
#attribute(name : Symbol)
Returns value by attribute name.
- #attributes : Hash(String, Array(Char) | Array(Float32) | Array(Float64) | Array(Int16) | Array(Int32) | Array(Int64) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | Time::Span | UInt32 | UUID | Nil)
-
#fields
Returns names of fields.
-
#inspect(io) : Nil
Returns a string containing a human-readable representation of object.
-
#to_json(only : Array(String)? = nil, except : Array(String)? = nil, &)
Returns a JSON string representing data set.
- #to_json(json : JSON::Builder)
- #to_json(json : JSON::Builder, only : Array(String)? = nil, except : Array(String)? = nil, &)
- #to_json(only : Array(String)? = nil, except : Array(String)? = nil)
Macro Summary
Constructor Detail
Instance Method Detail
Returns casted value of attribute name to the type type.
def attributes : Hash(String, Array(Char) | Array(Float32) | Array(Float64) | Array(Int16) | Array(Int32) | Array(Int64) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | Time::Span | UInt32 | UUID | Nil)
#
Returns a JSON string representing data set.
For more details see Resource#to_json
.