Features (features v0.1.0) View Source

Features enables or disables code sections with annotation.

Example

defmodule MyModule do
  use Features

  @doc "A doc for do_something/0 function."
  # this will enable the next function with his doc if :a_feature is in config
  @feature :a_feature
  def do_something do
    :a_feature_is_enabled

    # this will enable the next statement if :another_feature is in config
    @feature :another_feature
    :another_feature_is_enabled

    # this will enable the next statement if :another_feature is not in config
    @feature_off :another_feature
    :another_feature_is_disabled
  end
end

Code is automatically removed during compilation if the feature condition is not met.

A config example is the following:

config :features, features: [:a_feature]