https://github.com/codedge-llc/accessible
Dead-simple Access behavior for Elixir structs
https://github.com/codedge-llc/accessible
elixir hex
Last synced: 12 months ago
JSON representation
Dead-simple Access behavior for Elixir structs
- Host: GitHub
- URL: https://github.com/codedge-llc/accessible
- Owner: codedge-llc
- License: mit
- Created: 2017-12-19T17:53:48.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-08-31T18:53:40.000Z (over 1 year ago)
- Last Synced: 2025-03-24T10:18:10.420Z (12 months ago)
- Topics: elixir, hex
- Language: Elixir
- Homepage: https://hex.pm/packages/accessible
- Size: 37.1 KB
- Stars: 47
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Accessible
> Dead-simple Access behaviour for custom structs
[](https://github.com/codedge-llc/accessible/actions/workflows/ci.yml)
[](https://hex.pm/packages/accessible)
[](https://hex.pm/packages/accessible)
[](https://github.com/codedge-llc/accessible/blob/master/LICENSE.md)
[](https://github.com/codedge-llc/accessible/commits/master)
[](https://hexdocs.pm/accessible/)
## Installation
Add accessible as a `mix.exs` dependency:
```elixir
def deps do
[
{:accessible, "~> 0.3.0"}
]
end
```
## Usage
Add `use Accessible` to your struct's module to enable `Access` behavior.
```elixir
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.
```elixir
iex> %YourModule{}[:key]
1234
```
## Contributing
### Testing
Unit tests can be run with `mix test`.
### Formatting
This project uses Elixir's `mix format` and [Prettier](https://prettier.io) 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](http://karma-runner.github.io/5.0/dev/git-commit-msg.html).
## License
Copyright (c) 2017-2024 Codedge LLC (https://www.codedge.io/)
This library is MIT licensed. See the [LICENSE](https://github.com/codedge-llc/accessible/blob/master/LICENSE) for details.