suitepad-gmbh / pipette

Flow-Based Programming framework for Elixir
MIT License
21 stars 3 forks source link

[FEATURE] Add Pipette.OnDefinition to further improve the way recipe modules can be built #6

Closed Overbryd closed 6 years ago

Overbryd commented 6 years ago

Basic support for defining module based recipes. Now with less-magic™, and not forced upon the user. User can still use use Pipette.Recipe or define its very own module/controller start.

  defmodule ExampleRecipe do
    use Pipette.OnDefinition

    @subscribe foo: :IN
    @subscribe OUT: {:foo, :*}

    def foo("foo"), do: "bar"

    def foo("err"), do: {:error, "err"}

    def foo(val), do: val

  end
  defmodule AnotherExample do
    use Pipette.Recipe

    @subscribe foo: :IN
    @subscribe OUT: {:foo, :*}

    @stage foo: %Pipette.Stage{handler: fn
      "foo" -> "bar"
      val -> val
    end}

  end