Class: Strict::Interfaces::Coercer
- Inherits:
-
Object
- Object
- Strict::Interfaces::Coercer
- Defined in:
- lib/strict/interfaces/coercer.rb
Instance Attribute Summary collapse
-
#interface_class ⇒ Object
readonly
Returns the value of attribute interface_class.
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(interface_class) ⇒ Coercer
constructor
A new instance of Coercer.
Constructor Details
#initialize(interface_class) ⇒ Coercer
Returns a new instance of Coercer.
8 9 10 |
# File 'lib/strict/interfaces/coercer.rb', line 8 def initialize(interface_class) @interface_class = interface_class end |
Instance Attribute Details
#interface_class ⇒ Object (readonly)
Returns the value of attribute interface_class.
6 7 8 |
# File 'lib/strict/interfaces/coercer.rb', line 6 def interface_class @interface_class end |
Instance Method Details
#call(value) ⇒ Object
12 13 14 15 16 |
# File 'lib/strict/interfaces/coercer.rb', line 12 def call(value) return value if value.nil? || value.instance_of?(interface_class) interface_class.new(value) end |