Class: Definition::Types::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/definition/types/base.rb

Direct Known Subclasses

And, Each, Include, Keys, Lambda, Or, Type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/definition/types/base.rb', line 11

def initialize(name)
  self.name = name
end

Instance Attribute Details

#nameObject

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

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/definition/types/base.rb', line 22

def conform(_value)
  raise NotImplementedError
end

#explain(value) ⇒ Object



15
16
17
18
19
20
# File 'lib/definition/types/base.rb', line 15

def explain(value)
  result = conform(value)
  return "value passes definition" if result.passed?

  result.error_message
end