Class: Definition::Types::Base
- Inherits:
-
Object
- Object
- Definition::Types::Base
- Defined in:
- lib/definition/types/base.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #conform(_value) ⇒ Object
- #error_renderer ⇒ Object
- #explain(value) ⇒ Object
-
#initialize(name, context: {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(name, context: {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/definition/types/base.rb', line 12 def initialize(name, context: {}) self.name = name self.context = context end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
10 11 12 |
# File 'lib/definition/types/base.rb', line 10 def context @context end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/definition/types/base.rb', line 10 def name @name end |
Instance Method Details
#conform(_value) ⇒ Object
24 25 26 |
# File 'lib/definition/types/base.rb', line 24 def conform(_value) raise NotImplementedError end |
#error_renderer ⇒ Object
28 29 30 |
# File 'lib/definition/types/base.rb', line 28 def error_renderer ErrorRenderers::Standard end |
#explain(value) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/definition/types/base.rb', line 17 def explain(value) result = conform(value) return "value passes definition" if result.passed? result. end |