lib/peeky/api.rb
# Render a class using a predefined class renderer
#
# ^1: One of class_info and instance must supplied, they are mutually
# exclusive to each other.
#
# @param render_key [Symbol] class render key (required)
# @param class_info [Object] class_info: is optional^1, defaults to nil
# @param instance [Object] instance: is optional^1, defaults to nil
# @param _opts [<key: value>...] **_opts - list of key/values that can help configure render
Render a class using a predefined class renderer
^1: One of class_info and instance must supplied, they are mutually
exclusive to each other.
Render a class using a predefined class renderer ^1 : One of class_info and instance must supplied they are mutually exclusive to each other .
def render_class(render_key, class_info: nil, instance: nil, **_opts)
      raise 'Call render_class with class_info OR instance.' if class_info.nil? && instance.nil?
      raise 'Call render_class with class_info OR instance, these parameters are mutually exclusive' if !class_info.nil? && !instance.nil?
      renderer = class_renderer(render_key)
      class_info = Peeky::ClassInfo.new(instance) if class_info.nil?
      renderer.new(class_info).render
    end
def render_class ( render_key , class_info : nil , instance : nil , ** _opts ) raise 'Call render_class with class_info OR instance.' if class_info . nil? && instance . nil? raise 'Call render_class with class_info OR instance, these parameters are mutually exclusive' if ! class_info . nil? && ! instance . nil? renderer = class_renderer ( render_key ) class_info = Peeky :: ClassInfo . new ( instance ) if class_info . nil? renderer . new ( class_info ) . render end
Render a class using a predefined class renderer
^1: One of class_info and instance must supplied, they are mutually
exclusive to each other.
Render a class using a predefined class renderer ^1 : One of class_info and instance must supplied they are mutually exclusive to each other .
render_key
class render key (required)
class render key ( required )
class_info
None
nil
instance
None
nil
_opts
list of key/values that can help configure render
list of key / values that can help configure render