Class: Mappable::MapRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/mappable/map_router.rb

Class Method Summary collapse

Class Method Details

.build_map_route!(direction, map) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mappable/map_router.rb', line 13

def build_map_route!(direction, map)
  mapping_name = map.send(direction.to_sym)
  method_sym = "#{mapping_name}_#{map.subject}_#{map.attr}".camelize.to_sym
  Kernel.send :define_method, method_sym do |in_value|
    Mappable::MapRoute.new(map, in_value)
  end
end

.build_map_routes!Object



4
5
6
7
8
9
10
11
# File 'lib/mappable/map_router.rb', line 4

def build_map_routes!
  # this can get called before the database has been migrated
  return unless Mappable::Map.table_exists?
  Mappable::Map.all.each do |map|
    build_map_route!(:from, map)
    build_map_route!(:to, map)
  end
end