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.
23 24 25 |
# File 'lib/hotcocoa/mappings.rb', line 23 def mappings @mappings end |
Class Method Details
.load(framework) ⇒ Object
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 |
.map(name, &block) ⇒ Object
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 |
.reload ⇒ Object
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 |