Class: OrdDb::Model::Factory
- Inherits:
- 
      ActiveRecord::Base
      
        - Object
- ActiveRecord::Base
- OrdDb::Model::Factory
 
- Defined in:
- lib/ordlite/factory.rb,
 lib/ordlite/models/factory.rb,
 lib/ordlite/models/forward.rb
Class Method Summary collapse
- 
  
    
      .generators  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    use id/slug to cache generators / spritesheets - why? why not?. 
Instance Method Summary collapse
- 
  
    
      #_parse_dimension(str)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    e.g. 
- 
  
    
      #generate(*attributes)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    add g shortcut alias - why? why not?. 
- #generator ⇒ Object
- 
  
    
      #inscriberefs  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    join table (use habtm - why? why not?). 
Class Method Details
.generators ⇒ Object
use id/slug to cache generators / spritesheets - why? why not?
| 100 101 102 | # File 'lib/ordlite/factory.rb', line 100 def self.generators @generators ||= {} end | 
Instance Method Details
#_parse_dimension(str) ⇒ Object
e.g. convert dimension (width x height) “24x24” or “24 x 24” to [24,24]
| 126 127 128 | # File 'lib/ordlite/factory.rb', line 126 def _parse_dimension( str ) str.split( /x/i ).map { |str| str.strip.to_i(10) } end | 
#generate(*attributes) ⇒ Object
add g shortcut alias - why? why not?
| 120 121 122 | # File 'lib/ordlite/factory.rb', line 120 def generate( *attributes ) ## add g shortcut alias - why? why not? generator.generate( *attributes ) end | 
#generator ⇒ Object
| 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | # File 'lib/ordlite/factory.rb', line 104 def generator generators = self.class.generators if generators.has_key?( id ) generators[ id ] else ## auto-add generator on first-time/hit/demand width, height = _parse_dimension( dim ) inscribes = layers.to_a ## get layer inscribe records generator = FactoryGenerator.read_inscribes( *inscribes, width: width, height: height ) generators[ id ] = generator generator end end | 
#inscriberefs ⇒ Object
join table (use habtm - why? why not?)
| 10 | # File 'lib/ordlite/models/factory.rb', line 10 has_many :inscriberefs |