README.md

## ExApi
Library that allows you define api, its implementations and features.

### Library features:

1. Calling feature directly on implementation.
2. Calling feature from api using default implementation.
3. Calling feature from api using group and implementation id.
4. Checking api and implmentations.
5. Defining apis and their implementations.
6. Defining default implementation.
7. Grouping implementations.
8. Listing all apis, their features, implementations, specs and more.
9. Marking implementation features as supported, not supported and not implemented.
10. Registering and unregistering apis and implementations.

### Installation
Simply add `:ex_api` to your deps in `mix.exs` file and run command: `mix deps.get`.

    defp deps do
      [
        # ...
          {:ex_api, "~> 1.0.0-rc.1"},
        # ...
      ]
    end

### Why someone should use ExApi rather than `Behaviour` or `Protocol`?
We should use ExApi when we want to get list of implementations dynamically and when we do not have a target data type.

Example use case

Imagine that you are implementing unique api for similar services. First service could use JSON based api, second could use XML based api and so on …

Comparing to `Enum` module you do not need to have any useful data that you need to pass and work on them. Of course you could use empty struct or struct with data that you do not want to modify and/or use, but ... why?

As a developer you are going to make your code clean and short and here is solution for you. :-)

## Api Features
### Implementing feature
You can implement (or not) feature in 3 ways:

1. `:normal` - just implement it, see: `ExApi.Kernel.def_feature_impl/2`
2. `:not_supported` - mark feature as not supported (for example 3rd party api), see: `ExApi.Kernel.def_no_support/2`
3. `:not_implemented` - just don't implement feature and it will be automatically marked as not implemeted!

### Calling feature
You can call feature in four ways:

1. On each implementation, see: `ExApi.get_impls/1` or `YourApi.get_impls/0`
2. On default implementation, see: `ExApi.get_default_impl/1`  or `YourApi.get_default_impl/0`
3. On specified implementation, see: `ExApi.get_impl/2` or `YourApi.get_impl/1`
4. On specified implementation module, see: `YourImplementationModule` api.

### Preview features
You can see each feature status on related implementation api page or simply in `iex` by executing: `YourImplementation.__impl_info__`. Of course you can access to your implementation module in other ways too.

More information about each features could be find related extra api pages.


## Usage

Call `ExApi.Api.def_api/2` macro to define api:

    import ExApi.Api

    def_api MyApi do
      # docs, specs and features goes here ...
    end

Call `ExApi.Implementation.def_api_impl/5` macro to define api implementation:

    import ExApi.Implementation

    def_api_impl MyApi, :impl_id, ImplCustomModuleName do
      # set group, implement and/or mark as not supported `MyApi` features
    end

## Contributing

Feel free to share ideas. Describe a situation when you idea could be helpful. Examples and links to resources are also welcome.