Method: Malt::Machine#engine

Defined in:
lib/malt/machine.rb

#engine(type, engine = nil) ⇒ Object (private)



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/malt/machine.rb', line 214

def engine(type, engine=nil)
  type = ext_to_type(type)
  #engine = engine || Malt.config.engine[type]  # FIXME

  case engine
  when Class
    #raise unless Engine.registry[type].include?(engine)
    engine
  when String, Symbol
    match = engine.to_s.downcase.to_sym
    #Engine.registry[type].find{ |e| e.basename.downcase == match }
    #engines[type].find{ |e| e.basename.downcase == match }
    engines[type].find{ |e| match == e.type }
  else
    if engines[type]
      #Engine.registry[type].first
      types = engines[type]
      if prior = types.find{ |e| priority.include?(e.type) }
        return prior
      end
      if default = Engine.defaults[type]           
        return default #if engine?(default.type)
      end
      types.first
    else
      nil
    end
  end
end