Class: Oval::SubclassOf

Inherits:
ClassDeclBase show all
Defined in:
lib/oval/subclass_of.rb

Instance Attribute Summary

Attributes inherited from ClassDeclBase

#klass

Instance Method Summary collapse

Methods inherited from ClassDeclBase

[], #initialize

Methods inherited from Base

[], ensure_equal, #initialize, it_should, validate

Constructor Details

This class inherits a constructor from Oval::ClassDeclBase

Instance Method Details

#it_shouldObject


11
12
13
# File 'lib/oval/subclass_of.rb', line 11

def it_should
  "be a subclass of #{klass.name}"
end

#validate(thing, subject = nil) ⇒ Object


4
5
6
7
8
9
10
# File 'lib/oval/subclass_of.rb', line 4

def validate(thing, subject = nil)
  unless thing.is_a?(Class) and (thing < self.klass)
    raise Oval::ValueError,
      "Invalid class #{thing.inspect}#{for_subject(subject)}. " +
      "Should be subclass of #{klass.name}"
  end
end