Class: Interdependence::Types::FieldCoercer
- Inherits:
-
Object
- Object
- Interdependence::Types::FieldCoercer
- Defined in:
- lib/interdependence/types.rb
Overview
Coerce arguments into fields
Class Method Summary collapse
-
.call(value) ⇒ Field, UnsetField
private
Coerce different field values.
-
.success?(primitive, value) ⇒ TrueClass, FalseClass
private
Was the field successfully coerced into a field or UnsetField?.
Class Method Details
.call(value) ⇒ Field, UnsetField
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.
Coerce different field values
-
Coercions:
-
Symbol -> Field
-
Field -> clone
-
nil -> UnsetField
-
114 115 116 117 118 119 120 |
# File 'lib/interdependence/types.rb', line 114 def self.call(value) case value when Symbol then Field.new(value) when Field then value.clone when nil then UnsetField.new end end |
.success?(primitive, value) ⇒ TrueClass, FalseClass
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.
Was the field successfully coerced into a field or UnsetField?
131 132 133 |
# File 'lib/interdependence/types.rb', line 131 def self.success?(primitive, value) value.instance_of?(primitive) || value.instance_of?(UnsetField) end |