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.



420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/roda/plugins/render.rb', line 420

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.



437
438
439
440
441
442
443
444
445
446
447
# File 'lib/roda/plugins/render.rb', line 437

def inherited(subclass)
  super
  opts = subclass.opts[:render] = subclass.opts[:render].dup
  # :nocov:
  if COMPILED_METHOD_SUPPORT
  # :nocov:
    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.



450
451
452
# File 'lib/roda/plugins/render.rb', line 450

def render_opts
  opts[:render]
end