Class: Wee::StyleDecoration

Inherits:
WrapperDecoration show all
Defined in:
lib/wee/decoration.rb

Overview

Renders a CSS style for a component class.

Only works when used together with a PageDecoration, or an existing :styles divert location.

The style is not rendered when in an AJAX request. This is the desired behaviour as it is assumed that a component is first rendered via a regular request and then updated via AJAX requests.

It is only rendered once for all instances of a given component.

A method #style must exist returning the CSS style.

Instance Attribute Summary

Attributes inherited from Decoration

#next

Instance Method Summary collapse

Methods inherited from WrapperDecoration

#render_inner

Methods inherited from Decoration

#global?, #process_callbacks, #render!, #render_presenter!, #state

Methods inherited from Presenter

#process_callbacks, #render!, #renderer_class, #state

Constructor Details

#initialize(component) ⇒ StyleDecoration

Returns a new instance of StyleDecoration.



207
208
209
# File 'lib/wee/decoration.rb', line 207

def initialize(component)
  @component = component
end

Instance Method Details

#render(r) ⇒ Object



211
212
213
214
# File 'lib/wee/decoration.rb', line 211

def render(r)
  r.render_style(@component)
  render_inner(r)
end