Class: Eigindir::Coercer Private
- Inherits:
-
Object
- Object
- Eigindir::Coercer
- Defined in:
- lib/eigindir/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.
Class Coercer creates the proc to be called by attribute getter and setter
Class Method Summary collapse
-
.new(coerce: nil, strict: nil) ⇒ Eigindir::Coercer
private
Checks the coercer validity and creates its istance.
Instance Method Summary collapse
-
#call(instance, value) ⇒ Object
private
Coerces a value in a context of some instance.
-
#initialize(coerce: nil, strict: nil) ⇒ Coercer
constructor
private
A new instance of Coercer.
Constructor Details
#initialize(coerce: nil, strict: nil) ⇒ 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 Coercer.
23 24 25 26 27 28 |
# File 'lib/eigindir/coercer.rb', line 23 def initialize(coerce: nil, strict: nil) @coerce = coerce @strict = strict check_type check_arity end |
Class Method Details
.new(coerce: nil, strict: nil) ⇒ Eigindir::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.
Checks the coercer validity and creates its istance
18 19 20 |
# File 'lib/eigindir/coercer.rb', line 18 def self.new(coerce: nil, strict: nil) super if coerce end |
Instance Method Details
#call(instance, value) ⇒ 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.
Coerces a value in a context of some instance
38 39 40 |
# File 'lib/eigindir/coercer.rb', line 38 def call(instance, value) proc.call(instance, value) if value || strict end |