Module: Datamappify::Repository::MappingDSL

Includes:
LazyChecking
Defined in:
lib/datamappify/repository/mapping_dsl.rb

Instance Method Summary collapse

Methods included from LazyChecking

#assign_to_entity, #lazy_load?

Instance Method Details

#default_provider(provider_name) ⇒ void

This method returns an undefined value.

Parameters:

  • provider_name (String)

    name of data provider



22
23
24
# File 'lib/datamappify/repository/mapping_dsl.rb', line 22

def default_provider(provider_name)
  data_mapper.default_provider_name = provider_name.to_s
end

#for_entity(entity_class) ⇒ void

This method returns an undefined value.

If the entity is lazy loaded then it assigns the repository itself back to the entity

Parameters:

  • entity_class (Class)


12
13
14
15
16
# File 'lib/datamappify/repository/mapping_dsl.rb', line 12

def for_entity(entity_class)
  data_mapper.entity_class = entity_class

  assign_to_entity if lazy_load?
end

#group(options = {}) { ... } ⇒ void

This method returns an undefined value.

Parameters:

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

Yields:

  • a block containing ‘map_attribute` DSLs



39
40
41
42
43
44
45
# File 'lib/datamappify/repository/mapping_dsl.rb', line 39

def group(options = {}, &block)
  self.current_group_options = options

  block.call

  self.current_group_options = {}
end

#map_attribute(name, options = {}) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)

    name of the attribute

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


29
30
31
# File 'lib/datamappify/repository/mapping_dsl.rb', line 29

def map_attribute(name, options = {})
  data_mapper.custom_mapping[name.to_sym] = self.current_group_options.merge(options)
end