Class: Membrane::Schema::Class
- Defined in:
- lib/membrane/schema/class.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(klass) ⇒ Class
constructor
A new instance of Class.
-
#validate(object) ⇒ Object
Validates whether or not the supplied object is derived from klass.
Methods inherited from Base
Constructor Details
#initialize(klass) ⇒ Class
Returns a new instance of Class.
12 13 14 |
# File 'lib/membrane/schema/class.rb', line 12 def initialize(klass) @klass = klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
10 11 12 |
# File 'lib/membrane/schema/class.rb', line 10 def klass @klass end |
Instance Method Details
#validate(object) ⇒ Object
Validates whether or not the supplied object is derived from klass
17 18 19 20 21 22 23 |
# File 'lib/membrane/schema/class.rb', line 17 def validate(object) if !object.kind_of?(@klass) emsg = "Expected instance of #{@klass}," \ + " given an instance of #{object.class}" raise Membrane::SchemaValidationError.new(emsg) end end |