Skip to content

wli0503/Mixeur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mixeur

Mixin for Elixir

What it does?

It allows you to do mixin like in Ruby. For example:

I have an apple:

defmodule Apple do
  use Mixeur

  def apple do
    "Apple"
  end
end

I have a pen:

defmodule Pen do
  use Mixeur

  def pen do
    "Pen"
  end
end

Oh Oh Oh ApplePen:

defmodule ApplePen do
    use Apple
    use Pen

    def apple_pen do
      "#{apple()}#{pen()}"
    end
end

What's the difference between import and Mixeur?

Mixeur basically leverages defdelegate macro in Elixir. So not only it allows you to call functions inside a module(this behaviour is like import), also it exposes those functions to the outside world. For the example above, you can do:

iex> ApplePen.apple
"apple"
iex> ApplePen.pen
"pen"

Installation

If available in Hex, the package can be installed by adding mixeur to your list of dependencies in mix.exs:

def deps do
  [
    {:mixeur, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/mixeur.

About

Mix-in for Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages