PaginationEx.Config (PaginationEx v0.1.0)

Configuration module for PaginationEx.

This module provides configuration management for the PaginationEx library. It handles retrieval of configuration values from the application environment with fallback to default values, and provides access to essential configuration options like pagination limits and required dependencies.

Summary

Functions

Get configuration value with fallback to default.

Get gettext module configuration.

Get per group configuration.

Get per page configuration.

Get repo configuration.

Get router helpers module configuration.

Functions

get(key, default \\ nil)

@spec get(atom(), term()) :: term()

Get configuration value with fallback to default.

Parameters

  • key - The configuration key to look up under the :pagination_ex application environment
  • default - The default value to return if the key is not found

Returns

  • The configured value for the given key, or the provided default if not configured

Examples

# Assuming configuration:
# config :pagination_ex, :custom_setting, "custom_value"

iex> PaginationEx.Config.get(:custom_setting)
"custom_value"
iex> PaginationEx.Config.get(:missing_setting)
nil
iex> PaginationEx.Config.get(:missing_setting, "default")
"default"

gettext_module()

@spec gettext_module() :: module() | nil

Get gettext module configuration.

Returns

  • The configured :gettext_module, or nil if not configured

Examples

# With configuration:
# config :pagination_ex, :gettext_module, MyApp.Gettext
iex> PaginationEx.Config.gettext_module()
MyApp.Gettext

# Without configuration:
iex> PaginationEx.Config.gettext_module()
nil

per_group()

@spec per_group() :: non_neg_integer()

Get per group configuration.

Returns

  • The configured :per_group value, or 1000 if not configured

Examples

# With default configuration
iex> PaginationEx.Config.per_group()
1000

# With custom configuration:
# config :pagination_ex, :per_group, 500
iex> PaginationEx.Config.per_group()
500

per_page()

@spec per_page() :: non_neg_integer()

Get per page configuration.

Returns

  • The configured :per_page value, or 30 if not configured

Examples

# With default configuration
iex> PaginationEx.Config.per_page()
30

# With custom configuration:
# config :pagination_ex, :per_page, 50
iex> PaginationEx.Config.per_page()
50

repo()

@spec repo() :: module()

Get repo configuration.

Returns

  • The configured :repo module

Raises

  • Runtime error if :repo is not configured

Examples

# With configuration:
# config :pagination_ex, :repo, MyApp.Repo
iex> PaginationEx.Config.repo()
MyApp.Repo

# Without configuration:
iex> PaginationEx.Config.repo()
** (RuntimeError) You must configure a repo for PaginationEx...

router_helpers()

@spec router_helpers() :: module() | nil

Get router helpers module configuration.

Returns

  • The configured :router_helpers, or nil if not configured

Examples

# With configuration:
# config :pagination_ex, :router_helpers, MyAppWeb.Router.Helpers
iex> PaginationEx.Config.router_helpers()
MyAppWeb.Router.Helpers

# Without configuration:
iex> PaginationEx.Config.router_helpers()
nil