Module: StaticHelper

Defined in:
lib/static_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/static_helper.rb', line 5

def self.included(base)
  base.class_eval do
    alias_method_chain :render, :go_static
    alias_method_chain :render_to_string, :go_static
    after_filter :clean_temp_files
  end
end

Instance Method Details

#render_to_string_with_go_static(options = nil, *args, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/static_helper.rb', line 24

def render_to_string_with_go_static(options = nil, *args, &block)
  if options.is_a?(Hash) && options.has_key?(:png)
    log_png_creation
    options[:format] ||= "png"
    options[:basic_auth] = set_basic_auth(options)
    options.delete :png
    make_png((GoStatic.config || {}).merge(options))
  else
    render_to_string_without_go_static(options, *args, &block)
  end
end

#render_with_go_static(options = nil, *args, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/static_helper.rb', line 13

def render_with_go_static(options = nil, *args, &block)
  if options.is_a?(Hash) && options.has_key?(:png)
    log_png_creation
    options[:format] ||= "png"
    options[:basic_auth] = set_basic_auth(options)
    make_and_send_png(options.delete(:png), (GoStatic.config || {}).merge(options))
  else
    render_without_go_static(options, *args, &block)
  end
end