module Lucky::Assignable
Direct including types
Defined in:
lucky/assignable.crConstant Summary
-
ASSIGNS =
[] of Nil
Constructors
Macro Summary
- generate_needy_initializer
-
needs(*type_declarations)
Declare what a class needs in order to be initialized.
- setup_initializer_hook
Constructor Detail
Macro Detail
macro needs(*type_declarations)
#
Declare what a class needs in order to be initialized.
This will declare an instance variable and getter automatically. It will
also add arguments to an initialize
method at the end of compilation.
Examples
class Users::IndexPage < MainLayout
# This page needs a `User` or it will fail to compile
# You can access it with `@user` or the getter method `user`
needs user : User
# This page can take an optional `ProductQuery`. This means you can
# Leave `products` off when rendering from an Action.
needs products : ProductQuery?
# When using a `Bool` Lucky will generate a method ending with `?`
# So in this case you can call `should_show_sidebar?` in the page.
needs should_show_sidebar : Bool = true
end