class OpenComponents::UnrenderedComponent
Wrapper object for components using the ‘unrendered` rendering mode.
Public
↑ topAttributes
Public Class Methods
new(name, opts = {})
click to toggle source
Initializes a new UnrenderedComponent
.
- name
-
The String name of the component to request.
- opts
-
A Hash of options to use when requesting the component (default: {}).
- :params
-
A Hash of parameters to send in the component request (optional, default: {}).
- :version
-
The String version of the component to request (optional, default: nil).
- :headers
-
A Hash of HTTP request headers to include in the component request (optional, default:
DEFAULT_HEADERS
).
Calls superclass method
OpenComponents::Component::new
# File lib/opencomponents/unrendered_component.rb, line 24 def initialize(name, opts = {}) super(name, opts) @headers.merge!(DEFAULT_HEADERS) end
Public Instance Methods
load()
click to toggle source
Executes a request for the Component
against the configured registry and sets the component attributes.
Examples¶ ↑
component = OpenComponents::RenderedComponent.new('my-component') component.load # => #<OpenComponents::RenderedComponent: ... >
Returns¶ ↑
Returns the Component
with attributes set.
Calls superclass method
OpenComponents::Component#load
# File lib/opencomponents/unrendered_component.rb, line 40 def load template_data = response_data['template'] @data = response_data['data'] @template = Template.new( template_data['src'], template_data['type'], template_data['key'] ) super end
Internal
↑ topConstants
- DEFAULT_HEADERS
Default HTTP headers to send when requesting a component.