Class: Vedeu::Coercers::Coercer Private

Inherits:
Object
  • Object
show all
Includes:
Vedeu::Common
Defined in:
lib/vedeu/coercers/coercer.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 another value.

API:

  • private

Direct Known Subclasses

Chars, Colour, EditorLine, EditorLines, Lines, Page, Position, Row, Streams, Style

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#initialize(value, attributes = {}) ⇒ Vedeu::Coercers::Coercer

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 a new instance of the Vedeu::Coercers::Coercer subclass.

Parameters:

  • (defaults to: {})

API:

  • private



27
28
29
30
# File 'lib/vedeu/coercers/coercer.rb', line 27

def initialize(value, attributes = {})
  @value      = value
  @attributes = attributes
end

Instance Attribute Details

#attributesvoid (readonly, protected)

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.

This method returns an undefined value.

API:

  • private



41
42
43
# File 'lib/vedeu/coercers/coercer.rb', line 41

def attributes
  @attributes
end

#valuevoid (readonly, protected)

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.

This method returns an undefined value.

API:

  • private



45
46
47
# File 'lib/vedeu/coercers/coercer.rb', line 45

def value
  @value
end

Class Method Details

.coerce(value, attributes = {}) ⇒ Object

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.

Parameters:

  • (defaults to: {})

API:

  • private



17
18
19
# File 'lib/vedeu/coercers/coercer.rb', line 17

def self.coerce(value, attributes = {})
  new(value, attributes).coerce
end

Instance Method Details

#child_klassObject (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.

Raises:

  • When the method called should be handled by a subclass of the current class, or by the class including or extending the current module.

API:

  • private



50
51
52
# File 'lib/vedeu/coercers/coercer.rb', line 50

def child_klass
  raise Vedeu::Error::NotImplemented
end

#coerceObject

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.

Raises:

  • When the method called should be handled by a subclass of the current class, or by the class including or extending the current module.

API:

  • private



33
34
35
# File 'lib/vedeu/coercers/coercer.rb', line 33

def coerce
  raise Vedeu::Error::NotImplemented
end

#coerced?Boolean (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:

API:

  • private



55
56
57
# File 'lib/vedeu/coercers/coercer.rb', line 55

def coerced?
  value.is_a?(klass)
end

#incoercible!Object (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.

Raises:

  • When Vedeu does not understand that which the client application is attempting to achieve.

API:

  • private



60
61
62
63
# File 'lib/vedeu/coercers/coercer.rb', line 60

def incoercible!
  raise Vedeu::Error::Fatal,
        "Vedeu cannot coerce a '#{value.class.name}' into a '#{klass}'."
end

#klassObject (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.

Raises:

  • When the method called should be handled by a subclass of the current class, or by the class including or extending the current module.

API:

  • private



66
67
68
# File 'lib/vedeu/coercers/coercer.rb', line 66

def klass
  raise Vedeu::Error::NotImplemented
end