Skip to content

codedge-llc/accessible

Repository files navigation

Accessible

Dead-simple Access behaviour for custom structs

CI Version Total Downloads License Last Updated Documentation

Installation

Add accessible as a mix.exs dependency:

def deps do
  [
    {:accessible, "~> 0.3.0"}
  ]
end

Usage

Add use Accessible to your struct's module to enable Access behavior.

defmodule YourModule
  defstruct key: 1234, key_2: true

  use Accessible

  def your_function do
  ...
end

Your struct can now use all of the features of Access, including struct[:key] access syntax and Kernel nested get/update functions.

iex> %YourModule{}[:key]
1234

Contributing

Testing

Unit tests can be run with mix test.

Formatting

This project uses Elixir's mix format and Prettier for formatting. Add hooks in your editor of choice to run it after a save. Be sure it respects this project's .formatter.exs.

Commits

Git commit subjects use the Karma style.

License

Copyright (c) 2017-2024 Codedge LLC (https://www.codedge.io/)

This library is MIT licensed. See the LICENSE for details.