Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/techgaun/named_arguments
Python like named arguments in Elixir
https://github.com/techgaun/named_arguments
elixir named-arguments
Last synced: 13 days ago
JSON representation
Python like named arguments in Elixir
- Host: GitHub
- URL: https://github.com/techgaun/named_arguments
- Owner: techgaun
- License: mit
- Created: 2018-03-12T03:56:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-01T23:53:55.000Z (about 6 years ago)
- Last Synced: 2024-04-14T06:05:45.708Z (7 months ago)
- Topics: elixir, named-arguments
- Language: Elixir
- Size: 15.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# named_arguments [![Hex version](https://img.shields.io/hexpm/v/named_arguments.svg "Hex version")](https://hex.pm/packages/named_arguments) ![Hex downloads](https://img.shields.io/hexpm/dt/named_arguments.svg "Hex downloads") [![Build Status](https://travis-ci.org/techgaun/named_arguments.svg?branch=master)](https://travis-ci.org/techgaun/named_arguments)
> Named arguments in Elixir
This package abuses macros to use keyword lists
and maps to mimic named arguments in Elixir.Installation:
```elixir
{:named_arguments, "~> 0.1.0"}
```The usage is very simple:
```elixir
defmodule Analyzer do
use NamedArgumentsdef query(opts \\ [aggregate: :sum, range: "1h"]) do
IO.puts "running query with #{opts[:aggregate]} over range #{opts[:range]}"
end
endAnalyzer.query()
# running query with sum over range 1hAnalyzer.query(aggregate: :avg)
# running query with avg over range 1h
```While the above example shows Keyword list example, this works fine with maps as well.
You can check the [test](test/named_arguments_test.exs) for more examples.