Module: Roda::RodaPlugins::Render::ClassMethods

Defined in:
lib/roda/plugins/render.rb

Instance Method Summary collapse

Instance Method Details

#freezeObject

If using compiled methods and there is an optimized layout, speed up access to the layout method to improve the performance of view.



416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/roda/plugins/render.rb', line 416

def freeze
  begin
    _freeze_layout_method
  rescue
    # This is only for optimization, if any errors occur, they can be ignored.
    # One possibility for error is the app doesn't use a layout, but doesn't
    # specifically set the :layout=>false plugin option.
    nil
  end

  super
end

#inherited(subclass) ⇒ Object

Copy the rendering options into the subclass, duping them as necessary to prevent changes in the subclass affecting the parent class.



433
434
435
436
437
438
439
440
441
# File 'lib/roda/plugins/render.rb', line 433

def inherited(subclass)
  super
  opts = subclass.opts[:render] = subclass.opts[:render].dup
  if COMPILED_METHOD_SUPPORT
    opts[:template_method_cache] = (opts[:cache_class] || RodaCache).new
  end
  opts[:cache] = opts[:cache].dup
  opts.freeze
end

#render_optsObject

Return the render options for this class.



444
445
446
# File 'lib/roda/plugins/render.rb', line 444

def render_opts
  opts[:render]
end