paddle v0.1.4 Paddle.Class.Helper View Source

A helper module to help generate paddle classes.

There is currently two ways of generating paddle classes:

Using schema files

The simplest way is to find *.schema files which contain definitions of LDAP object classes. You can find them in the /etc/(open)ldap/schema/ directory if you have OpenLDAP installed. If not, you can find most of them here. Then, add the path of these files in the Paddle configuration using the :schema_files key (see the Paddle module toplevel documentation). Finally just call the gen_class_from_schema/3 macro from anywhere outside of a module.


require Paddle.Class.Helper
Paddle.Class.Helper.gen_class_from_schema MyApp.Room, ["room"], "ou=Rooms"

For a description of the parameters and more configuration options, see the gen_class_from_schema/3 macro documentation.

Manually describing the class

If you’re feeling more adventurous you can still use this helper you can also specify by hand each part of the class using the Paddle.Class.Helper.gen_class/2 macro (if that still doesn’t satisfy you, you can always look at the Paddle.Class protocol).

Example (which is equivalent to the example above):

require Paddle.Class.Helper
Paddle.Class.Helper.gen_class MyApp.Room,
  fields: [:commonName, :roomNumber, :description, :seeAlso, :telephoneNumber],
  unique_identifier: :commonName,
  object_classes: ["room"],
  required_attributes: [:commonName],
  location: "ou=Rooms"

The available options are all function names defined and documented in the Paddle.Class protocol, plus the :fields option which defines all the available fields for the given class.

Please note that using the :generators option here is discouraged as generators should be inside the module and not elsewhere. Unless you are sure what you are doing is elegant enough, you should define the module yourself instead of using this macro with the :generators option (see the Paddle.Class and the source of this macro for guidelines).

Link to this section Summary

Link to this section Functions

Link to this macro gen_class(class_name, options) View Source (macro)

Generate a Paddle class.

Generate a Paddle class represented as a struct with the name class_name, and the options options (see the module toplevel documentation).

Link to this macro gen_class_from_schema(class_name, object_classes, location, unique_identifier \\ nil, generators \\ []) View Source (macro)

Generate a Paddle class from schema files.

Generate a Paddle class from one of the schema files passed as configuration with the name class_name, with the given object_classes (can be a binary or a list of binary), at the given location, optionally force specify which field to use as a unique identifier (see Paddle.Class.unique_identifier/1), and some optional generators (see Paddle.Class.generators/1)