module

Lucky::Assignable

Constants

ASSIGNS = [] of Nil

Constructors

new

Macros

generate_needy_initializer
Source
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
Source
setup_initializer_hook
Source