Module: Wonkavision::MessageMapper
- Defined in:
- lib/wonkavision/message_mapper.rb,
lib/wonkavision/message_mapper/map.rb,
lib/wonkavision/message_mapper/indifferent_access.rb
Defined Under Namespace
Modules: IndifferentAccess
Classes: Map
Class Method Summary
collapse
Class Method Details
.execute(map, data_source, options = {}) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/wonkavision/message_mapper.rb', line 14
def execute(map,data_source,options={})
map_block = map.kind_of?(Proc) ? map : MessageMapper.maps[map]
raise "#{map} not found" unless map_block
MessageMapper::Map.new.execute(data_source, map_block, options)
end
|
.maps ⇒ Object
6
7
8
|
# File 'lib/wonkavision/message_mapper.rb', line 6
def maps
@maps ||={}
end
|
.register(map_name, &block) ⇒ Object
10
11
12
|
# File 'lib/wonkavision/message_mapper.rb', line 10
def register(map_name,&block)
MessageMapper.maps[map_name] = block
end
|
.register_map_directory(directory_path, recursive = true) ⇒ Object
21
22
23
24
|
# File 'lib/wonkavision/message_mapper.rb', line 21
def register_map_directory(directory_path, recursive=true)
searcher = "#{recursive ? "*" : "**/*"}.rb"
Dir[File.join(directory_path,searcher)].each {|map| require map}
end
|