Class: Interdependence::Types::OptionsCoercer
- Inherits:
-
Object
- Object
- Interdependence::Types::OptionsCoercer
- Defined in:
- lib/interdependence/types.rb
Overview
Coerce arguments into either a Hash or UnsetOptions
Class Method Summary collapse
-
.call(value) ⇒ Hash, UnsetOptions
private
Coerce different option values.
-
.success?(_, value) ⇒ TrueClass, FalseClass
private
Determine if value is a hash or unset.
Class Method Details
.call(value) ⇒ Hash, UnsetOptions
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 option values
-
Coercions:
-
true -> {}
-
nil -> UnsetOptions
-
any hash -> no change
-
152 153 154 155 156 157 158 |
# File 'lib/interdependence/types.rb', line 152 def self.call(value) case value when TrueClass then {} when Hash then value when nil then UnsetOptions.new end end |
.success?(_, 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.
Determine if value is a hash or unset
168 169 170 |
# File 'lib/interdependence/types.rb', line 168 def self.success?(_, value) value.instance_of?(Hash) || value.unset? end |