Module: HotCocoa::Mappings
- Defined in:
- lib/hotcocoa/mappings.rb
Defined Under Namespace
Modules: TargetActionConvenience Classes: Mapper
Class Attribute Summary (collapse)
-
+ (Hash{Symbol=>HotCocoa::Mappings::Mapper}) mappings
readonly
The cache of mappers for available mappings.
Class Method Summary (collapse)
-
+ (Object) load(framework)
Load mappings for a given framework.
-
+ (Object) map(name, &block)
Create a new mapping by registering
mapped_nameas a builder method formapped_class. -
+ (Object) reload
Load mappings for every loaded framework.
Class Attribute Details
+ (Hash{Symbol=>HotCocoa::Mappings::Mapper}) mappings (readonly)
The cache of mappers for available mappings.
23 24 25 |
# File 'lib/hotcocoa/mappings.rb', line 23 def mappings @mappings end |
Class Method Details
+ (Object) load(framework)
Load mappings for a given framework.
35 36 37 38 39 40 41 42 43 |
# File 'lib/hotcocoa/mappings.rb', line 35 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 |
+ (Object) map(name, &block)
Create a new mapping by registering mapped_name as a builder
method for mapped_class.
57 58 59 60 61 |
# File 'lib/hotcocoa/mappings.rb', line 57 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 |
+ (Object) reload
Load mappings for every loaded framework.
27 28 29 |
# File 'lib/hotcocoa/mappings.rb', line 27 def reload $LOADED_FRAMEWORKS.each do |framework| load framework end end |