View Source HypeLib.Prelude (HypeLib v2.4.1)

The Prelude module contains utility functions for working with external dependencies like TypeCheck, the Elixir Logger moudle etc.

Link to this section Summary

Functions

Imports TypeCheck and requires the Erlang logger

Imports the Ecto schema functions and all changeset functions

Imports the Absinthe notation module

Imports the graphql AST and uses the Absinthe.Schema

Imports the HypeLib.Utils.String module as StringUtils into the current context.

Changelog

2.3.1

Link to this section Functions

@spec core() :: Macro.t()
@spec core() :: Macro.t()

Imports TypeCheck and requires the Erlang logger

changelog

Changelog

1-0-0

1.0.0

Initial release

@spec entity() :: Macro.t()
@spec entity() :: Macro.t()

Imports the Ecto schema functions and all changeset functions

usage

Usage

This macro adds an module attribute to the calling module for defining ecto timestamps as DateTime structs instead of NaiveDateTime.

Hint: Do not forget to configure your application to use timestamps with timezone information:

config :my_app,
    MyApp.Repo,
    migration_timestamps: [
      type: :utc_datetime
    ]

You might want to install Timex for DateTime convenience functions like creating and manipulating the date or time.

Run the following command to view the latest version of Timex:

mix hex.info timex

changelog

Changelog

2-2-0

2.2.0

  • Added the Database alias
  • Added timezone support
  • Added the Usage section

1-0-0

1.0.0

Initial release

@spec graphql() :: Macro.t()
@spec graphql() :: Macro.t()

Imports the Absinthe notation module

changelog

Changelog

2-2-0

2.2.0

  • Added the GraphQL alias

1-0-0

1.0.0

Initial release

@spec graphql_schema() :: Macro.t()
@spec graphql_schema() :: Macro.t()

Imports the graphql AST and uses the Absinthe.Schema

changelog

Changelog

2-2-0

2.2.0

Initial release

@spec string() :: Macro.t()
@spec string() :: Macro.t()

Imports the HypeLib.Utils.String module as StringUtils into the current context.

examples

Examples

iex> defmodule TokenGenerator do
...>   use HypeLib.Prelude, :string
...>
...>   @spec! generate_token() :: String.t()
...>   def generate_token() do
...>     StringUtils.Generator.generate_string!(1, ~w(a))
...>   end
...> end
...>
...> TokenGenerator.generate_token()
"a"

changelog

Changelog

1-0-0

1.0.0

Initial release

@spec url() :: Macro.t()
@spec url() :: Macro.t()

changelog

Changelog

2-3-1

2.3.1