Module: Stale::View

Includes:
Fragments
Defined in:
lib/stale/view.rb

Instance Method Summary collapse

Methods included from Fragments

#read_stale_fragment, #stale_fragment_exist?, #write_stale_fragment

Instance Method Details

#stale(parameters, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/stale/view.rb', line 5

def stale(parameters, &block)
  if !controller.perform_caching
    safe_concat(build_stale_fragment(&block))
    return
  end

  key = Stale.interface.key_for_parameters(parameters, controller)
  Stale.interface.register_dependencies(key)

  unless fragment = read_stale_fragment(key)
    fragment = build_stale_fragment(&block)
    write_stale_fragment(key, fragment)
  end

  safe_concat(fragment)
  nil
end