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
- #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.
11 12 13 14 |
# File 'lib/definition/types/base.rb', line 11 def initialize(name, context: {}) self.name = name self.context = context end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
9 10 11 |
# File 'lib/definition/types/base.rb', line 9 def context @context end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/definition/types/base.rb', line 9 def name @name end |
Instance Method Details
#conform(_value) ⇒ Object
23 24 25 |
# File 'lib/definition/types/base.rb', line 23 def conform(_value) raise NotImplementedError end |
#explain(value) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/definition/types/base.rb', line 16 def explain(value) result = conform(value) return "value passes definition" if result.passed? result. end |