Module: Usher::Interface

Defined in:
lib/usher/interface.rb,
lib/usher/interface/merb.rb,
lib/usher/interface/rack.rb,
lib/usher/interface/text.rb,
lib/usher/interface/email.rb,
lib/usher/interface/rails3.rb,
lib/usher/interface/rails20.rb,
lib/usher/interface/rails22.rb,
lib/usher/interface/rails23.rb,
lib/usher/interface/sinatra.rb,
lib/usher/interface/rails22/mapper.rb,
lib/usher/interface/rails23/mapper.rb

Defined Under Namespace

Classes: Email, Merb, Rack, Rails20, Rails22, Rails23, Rails3, Sinatra, Text

Constant Summary collapse

InterfaceRegistry =
{}

Class Method Summary collapse

Class Method Details

.class_for(name) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/usher/interface.rb', line 20

def self.class_for(name)
  name = name.to_sym
  if InterfaceRegistry[name]
    require InterfaceRegistry[name]
    Usher::Interface.const_get(File.basename(InterfaceRegistry[name]).to_s.split(/_/).map{|e| e.capitalize}.join)
  else
    raise ArgumentError, "Interface #{name.inspect} doesn't exist. Choose one of: #{InterfaceRegistry.keys.inspect}"
  end
end

.for(name, *args, &block) ⇒ Object

Usher::Interface.for(:rack, &block)



31
32
33
# File 'lib/usher/interface.rb', line 31

def self.for(name, *args, &block)
  class_for(name).new(*args, &block)
end

.register(name, cls) ⇒ Object



6
7
8
# File 'lib/usher/interface.rb', line 6

def self.register(name, cls)
  InterfaceRegistry[name] = cls
end