Class: Tilt::Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/homura_vendor_tilt.rb

Instance Method Summary collapse

Constructor Details

#initializeMapping

Returns a new instance of Mapping.



21
22
23
# File 'lib/homura_vendor_tilt.rb', line 21

def initialize
  @extensions = {}
end

Instance Method Details

#[](name) ⇒ Object



29
30
31
# File 'lib/homura_vendor_tilt.rb', line 29

def [](name)
  @extensions[name.to_s]
end

#extensions_for(engine_or_class) ⇒ Object



33
34
35
36
37
# File 'lib/homura_vendor_tilt.rb', line 33

def extensions_for(engine_or_class)
  @extensions.each_with_object([]) do |(ext, klass), out|
    out << ext if klass == engine_or_class
  end
end

#register(template_class, *extensions) ⇒ Object



25
26
27
# File 'lib/homura_vendor_tilt.rb', line 25

def register(template_class, *extensions)
  extensions.each { |ext| @extensions[ext.to_s] = template_class }
end

#template_for(name) ⇒ Object



39
40
41
# File 'lib/homura_vendor_tilt.rb', line 39

def template_for(name)
  @extensions[name.to_s]
end