Giter VIP home page Giter VIP logo

c3p0's Introduction

C3P0

C3P0 contains protocol definitions.

Centralizing these definitions, it is hoped that libraries and applications will make use of them to make data more portable between components of a system.

Protocols

ID

This protocol standardizes finding an ID for a peice of data.

There are two functions in this protocol:

  1. C3P0.ID.id(data)
  2. C3P0.ID.guid(data)

By default the guid will fall back to the id.

This will work on all structs and maps which have fields id (and optionally guid)

To customize for your struct if there are different fields, derive the C3P0.ID protocol.

defmodule MyStruct do
  @derive {C3P0.ID, id_field: :local_id, guid_field: :global_id}
  defstruct [:local_id, :global_id]
end

Humanize

The C3P0.Humanize protocol displays as a string the data provided.

Falls back to a simple to_string

Blank

The C3P0.Blank protocol deals with blankness.

Empty strings, bbinaries, lists, maps and tuples are considered blank? along with nil.

The protocol defines 3 functions:

  • blank?(data) - true/false
  • present?(data) - true/false
  • presence(data) - returns the value if it is not blank. nil if it is blank

Contributing

We love contributions and they're welcome here!

C3P0 is aiming to be a central collection of useful protocols and we'd love more protocols that folks find useful.

Please raise an issue or submit a PR. Protocols can be really powerful especially if everyone uses the same ones.

Installation

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

def deps do
  [
    {:c3p0, "~> 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/c3p0.

c3p0's People

Contributors

hassox avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.