Module: Vedeu::Presentation::Styles
Overview
Provides style related presentation behaviour.
Instance Method Summary collapse
- #name ⇒ NilClass|String|Symbol
- #parent ⇒ NilClass|void
-
#render_style(&block) ⇒ String
private
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
-
#style ⇒ Vedeu::Presentation::Style
When the style for the model exists, return it, otherwise returns the parent style, or an empty Style.
-
#style=(value) ⇒ Vedeu::Presentation::Style
Allows the setting of the style by coercing the given value into a Style.
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Instance Method Details
#name ⇒ NilClass|String|Symbol
14 15 16 17 18 19 20 21 22 |
# File 'lib/vedeu/presentation/styles.rb', line 14 def name if present?(@name) @name elsif parent && present?(parent.name) parent.name end end |
#parent ⇒ NilClass|void
25 26 27 |
# File 'lib/vedeu/presentation/styles.rb', line 25 def parent present?(@parent) ? @parent : nil end |
#render_style(&block) ⇒ String (private)
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
62 63 64 |
# File 'lib/vedeu/presentation/styles.rb', line 62 def render_style(&block) "#{style}#{yield}" end |
#style ⇒ Vedeu::Presentation::Style
When the style for the model exists, return it, otherwise returns the parent style, or an empty Vedeu::Presentation::Style.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vedeu/presentation/styles.rb', line 34 def style @_style ||= if @style Vedeu::Presentation::Style.coerce(@style) elsif parent && present?(parent.style) Vedeu::Presentation::Style.coerce(parent.style) else Vedeu::Presentation::Style.new end end |
#style=(value) ⇒ Vedeu::Presentation::Style
Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.
51 52 53 |
# File 'lib/vedeu/presentation/styles.rb', line 51 def style=(value) @_style = @style = Vedeu::Presentation::Style.coerce(value) end |