Class: Laborantin::Metaprog::Verifications::Verification

Inherits:
Object
  • Object
show all
Includes:
Describable, Resolutions, InstanceMethods
Defined in:
lib/laborantin/core/verifications.rb

Instance Attribute Summary collapse

Attributes included from InstanceMethods

#verifications

Attributes included from Resolutions::InstanceMethods

#resolutions

Attributes included from Describable

#description

Instance Method Summary collapse

Methods included from InstanceMethods

#valid?, #verify

Methods included from Resolutions::InstanceMethods

#resolve, #resolve!

Constructor Details

#initialize(name) ⇒ Verification

Returns a new instance of Verification.



31
32
33
# File 'lib/laborantin/core/verifications.rb', line 31

def initialize(name)
  @name = name
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



30
31
32
# File 'lib/laborantin/core/verifications.rb', line 30

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/laborantin/core/verifications.rb', line 30

def name
  @name
end

Instance Method Details

#check(&blk) ⇒ Object



35
36
37
# File 'lib/laborantin/core/verifications.rb', line 35

def check(&blk)
  @block = blk
end

#correct?(*ary) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (RuntimeError)


39
40
41
42
# File 'lib/laborantin/core/verifications.rb', line 39

def correct?(*ary)
  raise RuntimeError, "no block for verification #{self}" unless block
  block.call(*ary) && valid?(*ary)
end