Module: LittleMapper

Defined in:
lib/little_mapper.rb,
lib/little_mapper/version.rb,
lib/little_mapper/mappers/mappers.rb,
lib/little_mapper/mapping_factory.rb,
lib/little_mapper/dsl_class_methods.rb,
lib/little_mapper/result/repo_failure.rb,
lib/little_mapper/result/repo_success.rb,
lib/little_mapper/result/repo_response.rb,
lib/little_mapper/mappers/AR/one_to_one.rb,
lib/little_mapper/mappers/AR/one_to_many.rb,
lib/little_mapper/mapper_instance_methods.rb

Defined Under Namespace

Modules: DslClassMethods, MapperInstanceMethods, Mappers, Result Classes: MappingFactory

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

Returns an instantiated mapper for the given key.

The primary way of interacting with LittleMapper having set up one or more mappers.

key - The key under which the mapper was stored. Generally the non-

persistent entity class name.

Returns a mapper instance for the key



37
38
39
# File 'lib/little_mapper.rb', line 37

def self.[](key)
  @mappers[key].new
end

.included(klass) ⇒ Object

Private: kicks off the action when this module is included



42
43
44
45
# File 'lib/little_mapper.rb', line 42

def self.included(klass)
  klass.extend DslClassMethods
  klass.module_eval { include MapperInstanceMethods}
end

.register(entity, mapper) ⇒ Object

Registers a mapper under a key.

Will generally be called by Little Mapper itself during inclusion of the LittleMapper module in your class.

entity - The key under which the mapper will be held. Generally the

the non-persistent entity class name.

mapper - The class of the mapper.

Returns the mapper



23
24
25
26
# File 'lib/little_mapper.rb', line 23

def self.register(entity, mapper)
  @mappers ||= {}
  @mappers[entity] = mapper
end