Module: HotCocoa::Mappings
- Defined in:
- lib/hotcocoa/mappings.rb
Defined Under Namespace
Modules: TargetActionConvenience Classes: Mapper
Class Attribute Summary collapse
-
.mappings ⇒ Hash{Symbol=>HotCocoa::Mappings::Mapper}
readonly
The cache of mappers for available mappings.
Class Method Summary collapse
-
.load(framework) ⇒ Object
Load mappings for a given framework.
-
.map(name, &block) ⇒ Object
Create a new mapping by registering
mapped_name
as a builder method formapped_class
. -
.reload ⇒ Object
Load mappings for every loaded framework.
Class Attribute Details
.mappings ⇒ Hash{Symbol=>HotCocoa::Mappings::Mapper} (readonly)
The cache of mappers for available mappings.
21 22 23 |
# File 'lib/hotcocoa/mappings.rb', line 21 def mappings @mappings end |
Class Method Details
.load(framework) ⇒ Object
Load mappings for a given framework.
33 34 35 36 37 38 39 40 41 |
# File 'lib/hotcocoa/mappings.rb', line 33 def load framework framework = framework.downcase dir = File.join(@path, framework) if Dir.exists? dir Dir.glob(File.join(dir, '**/*.rb')).each do |mapping| require mapping.chomp! '.rb' end end end |
.map(name, &block) ⇒ Object
Create a new mapping by registering mapped_name
as a builder
method for mapped_class
.
55 56 57 58 59 |
# File 'lib/hotcocoa/mappings.rb', line 55 def map name, &block mapped_name, mapped_class = name.first mappings[mapped_name] = HotCocoa::Mappings::Mapper.map_instances_of mapped_class, mapped_name, &block end |
.reload ⇒ Object
Load mappings for every loaded framework.
25 26 27 |
# File 'lib/hotcocoa/mappings.rb', line 25 def reload $LOADED_FRAMEWORKS.each do |framework| load framework end end |