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.



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

def initialize
  @extensions = {}
end

Instance Method Details

#[](name) ⇒ Object



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

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

#extensions_for(engine_or_class) ⇒ Object



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

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



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

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

#template_for(name) ⇒ Object



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

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