Class: Vedeu::Coercers::Style Private

Inherits:
Coercer
  • Object
show all
Defined in:
lib/vedeu/coercers/style.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides the mechanism to convert a value into a Presentation::Style.

Instance Attribute Summary

Attributes inherited from Coercer

#attributes, #value

Instance Method Summary collapse

Methods inherited from Coercer

#child_klass, coerce, #coerced?, #incoercible!, #initialize

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

This class inherits a constructor from Vedeu::Coercers::Coercer

Instance Method Details

#coerceVedeu::Presentation::Style

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Produces new objects of the correct class from the value, ignores objects that have already been coerced.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vedeu/coercers/style.rb', line 18

def coerce
  if coerced?
    value

  elsif hash?(value)
    if present?(value[:style])
      if value[:style].is_a?(klass)
        value[:style]

      else
        Vedeu::Coercers::Style.coerce(value[:style])

      end

    else
      klass.new

    end

  else
    klass.new(value)

  end
end

#klassClass (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Class)


46
47
48
# File 'lib/vedeu/coercers/style.rb', line 46

def klass
  Vedeu::Presentation::Style
end