Class: Occi::Core::Renderers::Text::Collection
- Defined in:
- lib/occi/core/renderers/text/collection.rb
Overview
Implements methods needed to render collection instances to text-based renderings. This class (its instances) is usually called directly from the “outside”. It utilizes ‘Model` from this module to render kinds, actions, and mixins. As well as `Resource`, `Link`, and `ActionInstance`.
Constant Summary
Constants inherited from Base
Base::DELEGATED, Base::RENDER_SAFE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#render_headers ⇒ Hash
Renders ‘object` into text for headers and returns the result as `Hash`.
-
#render_plain ⇒ String
Renders ‘object` into plain text and returns the result as `String`.
Methods inherited from Base
#initialize, #render, #render_safe, render_safe
Constructor Details
This class inherits a constructor from Occi::Core::Renderers::Text::Base
Instance Method Details
#render_headers ⇒ Hash
Renders ‘object` into text for headers and returns the result as `Hash`.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/occi/core/renderers/text/collection.rb', line 35 def render_headers return {} if object_empty? || object.only_categories? if ent_no_ai? prepare_instances 'entities' elsif ai_no_ent? prepare_instances 'action_instances' else raise Occi::Core::Errors::RenderingError, 'Cannot render mixed collection to text headers' end end |
#render_plain ⇒ String
Renders ‘object` into plain text and returns the result as `String`.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/occi/core/renderers/text/collection.rb', line 18 def render_plain return '' if object_empty? || object.only_categories? if ent_no_ai? prepare_instances 'entities' elsif ai_no_ent? prepare_instances 'action_instances' else raise Occi::Core::Errors::RenderingError, 'Cannot render mixed collection to plain text' end end |