Class: Pakyow::Validations::Inline Private
- Inherits:
-
Object
- Object
- Pakyow::Validations::Inline
- Extended by:
- Forwardable
- Defined in:
- lib/pakyow/validations/inline.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.
Wraps an inline validation proc so that we know its given name.
Instance Attribute Summary collapse
- #name ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(name, block) ⇒ Inline
constructor
private
A new instance of Inline.
- #message ⇒ Object private
- #valid?(value, context: nil) ⇒ Boolean private
Constructor Details
#initialize(name, block) ⇒ Inline
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 Inline.
15 16 17 |
# File 'lib/pakyow/validations/inline.rb', line 15 def initialize(name, block) @name, @block = name, block end |
Instance Attribute Details
#name ⇒ Object (readonly)
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.
13 14 15 |
# File 'lib/pakyow/validations/inline.rb', line 13 def name @name end |
Instance Method Details
#message ⇒ 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.
19 20 21 |
# File 'lib/pakyow/validations/inline.rb', line 19 def (**) "is invalid" end |
#valid?(value, context: nil) ⇒ Boolean
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.
23 24 25 26 27 28 29 |
# File 'lib/pakyow/validations/inline.rb', line 23 def valid?(value, context: nil, **) if context context.instance_exec(value, &@block) else @block.call(value) end end |