Class: CssViews::Handler

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration, controller) ⇒ Handler

Returns a new instance of Handler.



3
4
5
6
# File 'lib/css_views/handler.rb', line 3

def initialize(configuration, controller)
  @configuration = configuration
  @controller = controller
end

Instance Method Details

#bodyObject



12
13
14
15
16
# File 'lib/css_views/handler.rb', line 12

def body
  @configuration.components.map do |view|
    @controller.send(:render_to_string, view)
  end.join("\n")
end

#etagObject



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

def etag
  template_files.map {|f| File.mtime(f) }
end

#last_modifiedObject



18
19
20
# File 'lib/css_views/handler.rb', line 18

def last_modified
  template_files.map {|f| File.mtime(f) }.max
end

#renderObject



8
9
10
# File 'lib/css_views/handler.rb', line 8

def render
  transform(body)
end

#transform(css) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/css_views/handler.rb', line 26

def transform(css)
  if transformers = @configuration.transformers
    transformers.each do |transformer|
      css = transformer.transform(css)
    end
  end
  css
end