Module: Vedeu::Presentation::Styles

Includes:
Common
Included in:
Vedeu::Presentation
Defined in:
lib/vedeu/presentation/styles.rb

Overview

Provides style related presentation behaviour.

Instance Method Summary collapse

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

#nameNilClass|String|Symbol

Returns:

  • (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

#parentNilClass|void

Returns:

  • (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).

Parameters:

  • block (Proc)

Returns:

  • (String)


62
63
64
# File 'lib/vedeu/presentation/styles.rb', line 62

def render_style(&block)
  "#{style}#{yield}"
end

#styleVedeu::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