module Change

Defined in:

change.cr
change/changeset.cr
change/changeset/errors.cr
change/changeset/validations.cr
change/schema.cr
change/sql.cr
change/sql/postgres_query.cr
change/sql/query.cr
change/sql/repo.cr
change/typecast.cr
change/typecast/json.cr

Constant Summary

VERSION = "0.1.0"

Macro Summary

Macro Detail

macro field(prop, **opts) #

Define a nilable property on the caller and for the Changeset it generates. The generated property will automatically be made Nilable, but the default accessor will raise on nil. If the field is expected to be nil, use prop? to access the field instead.

prop is expected to be a TypeDeclaration (e.g. name : String), just as is used when calling property, including setting a default value, or adding any annotations.

opts is currently unused, but will be passed along to the generated changeset fields to modify them further.


[View source]
macro field!(prop, **opts) #

Exactly like field, but the generated field is non-nilable.


[View source]
macro gen_changeset(type) #

Generate a custom Changeset struct for the given type. properties will also be generated as properties on the type itself. properties should not include any nilable types, as they will be added automatically on generation. By default, normal accessors will be non- nilable, and query accessors (e.g. name?) can be used if a nil value may be expected.

Rather than enforcing nilability on the field type itself, it is instead managed by the Changeset's casting, validations, and other constraints.


[View source]