Module: Vorpal::Dsl::Configuration

Included in:
Vorpal
Defined in:
lib/vorpal/dsl/configuration.rb

Instance Method Summary collapse

Instance Method Details

#define(options = {}, &block) ⇒ Engine

Configures and creates a Engine instance.

Parameters:

  • options (Hash) (defaults to: {})

    Global configuration options for the engine instance.

Options Hash (options):

  • :db_driver (Object) — default: Object that will be used to interact with the DB.

    Must be duck-type compatible with Postgresql.

Returns:

  • (Engine)

    Instance of the mapping engine.



16
17
18
19
20
# File 'lib/vorpal/dsl/configuration.rb', line 16

def define(options={}, &block)
  master_config = build_config(&block)
  db_driver = options.fetch(:db_driver, Driver::Postgresql.new)
  Engine.new(db_driver, master_config)
end

#map(domain_class, options = {}, &block) ⇒ Object

Maps a domain class to a relational table.

Parameters:

  • domain_class (Class)

    Type of the domain model to be mapped

  • options (Hash) (defaults to: {})

    Configure how to map the domain model

Options Hash (options):

  • :to (String)

    Class of the ActiveRecord object that will map this domain class to the DB. Optional, if one is not specified, it will be generated.

  • :serializer (Object) — default: map the {ConfigBuilder#attributes} directly

    Object that will convert the domain objects into a hash.

    Must have a (Hash) serialize(Object) method.

  • :deserializer (Object) — default: map the {ConfigBuilder#attributes} directly

    Object that will set a hash of attribute_names->values onto a new domain object.

    Must have a (Object) deserialize(Object, Hash) method.



38
39
40
# File 'lib/vorpal/dsl/configuration.rb', line 38

def map(domain_class, options={}, &block)
  @class_configs << build_class_config(domain_class, options, &block)
end