Implementes components common to all rendereres. It is not intended for direct use.
@abstract Not for direct use. @author Boris Parak <parak@cesnet.cz>
Returns a list of formats supported by this renderer. Formats are compliant with method naming restrictions and String-like.
@return [Array] list of formats
# File lib/occi/core/renderers/base_renderer.rb, line 24 def formats [] end
Returns a frozen Hash providing mapping information between supported types and supported serializers.
@return [Array] list of known type->serializer mappings
# File lib/occi/core/renderers/base_renderer.rb, line 66 def known {} end
Returns the list of known (and supported) serializer classes. Every element in the list is a fully namespaced classes.
@return [Array] list of known serializers
# File lib/occi/core/renderers/base_renderer.rb, line 58 def known_serializers known.values end
Returns the list of known (and supported) types for serialization. Every element in the list is a string representing a fully namespaced class name.
@return [Array] list of known types
# File lib/occi/core/renderers/base_renderer.rb, line 50 def known_types known.keys end
Renders the given `object` into a rendering in `options`.
@param object [Object] instance to be rendered @param options [Hash] additional rendering options @option options [String] :format (nil) rendering (sub)type @return [String] object rendering
# File lib/occi/core/renderers/base_renderer.rb, line 34 def render(object, options) logger.debug "#{self} rendering #{object.inspect} with #{options.inspect}" candidate = rendering_candidate(object) unless candidate raise Occi::Core::Errors::RenderingError, "#{object.class} cannot be " "rendered to #{options[:format]}" end known[candidate].new(object, options).render end
Indicates whether this class is a renderer candidate.
@return [TrueClass, FalseClass] renderer flag
# File lib/occi/core/renderers/base_renderer.rb, line 15 def renderer? false end