Module: Aws::Templates::Render

Included in:
Utils::BaseTypeViews, Utils::Inspect, Utils::Stringify
Defined in:
lib/aws/templates/render.rb,
lib/aws/templates/render/view.rb,
lib/aws/templates/render/registry.rb,
lib/aws/templates/render/utils/inspect.rb,
lib/aws/templates/render/utils/stringify.rb,
lib/aws/templates/render/utils/base_type_views.rb

Overview

View layer of the MVC pattern

View layer provides means of defining “views” of your artifacts to define different ways of rendering the object hierarchies you create to end representation.

The module also contains a few mixin methods to simplify creation of “renders” - collections of views defining the same domain representation. For instance JSON, LDIF, Wiki could be such final destinations.

Renders could be classes or modules. Modules work best if no customization is needed and you want a singleton.

Example

class Wiki
  include Aws::Templates::Render
end

module JSON
  extend Aws::Templates::Render
end

Defined Under Namespace

Modules: Utils Classes: BasicView, Registry, View

Instance Method Summary collapse

Instance Method Details

#can_render?(*args) ⇒ Boolean

Proxy for Registry can_render? method

Returns:

  • (Boolean)


49
50
51
# File 'lib/aws/templates/render.rb', line 49

def can_render?(*args)
  registry.can_render?(*args)
end

#define_view(artifact_class, view = nil, &blk) ⇒ Object

Define view for artifact

Another way to define views for artifacts. Creates anonymous class and attaches as the view to the specified artifact



64
65
66
67
68
69
# File 'lib/aws/templates/render.rb', line 64

def define_view(artifact_class, view = nil, &blk)
  Class
    .new(view || Aws::Templates::Render::BasicView, &blk)
    .register_in(self)
    .artifact(artifact_class)
end

#register(*args) ⇒ Object

Proxy for Registry register method



43
44
45
# File 'lib/aws/templates/render.rb', line 43

def register(*args)
  registry.register(*args)
end

#registryObject

Registry accessor

All views and corresponding artifacts in a render are stored in a registry.



37
38
39
# File 'lib/aws/templates/render.rb', line 37

def registry
  @registry ||= Registry.new
end

#view_for(*args) ⇒ Object

Proxy for Registry view_for method



55
56
57
# File 'lib/aws/templates/render.rb', line 55

def view_for(*args)
  registry.view_for(*args)
end