Sha256: a3f11f8f1d91b983629dfd69f80f512d854ece4f402cbd5573a924bc096a17fe

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

require "membrane/errors"
require "membrane/schema/base"

module Membrane
  module Schema
  end
end

class Membrane::Schema::Class < Membrane::Schema::Base
  attr_reader :klass

  def initialize(klass)
    @klass = klass
  end

  # Validates whether or not the supplied object is derived from klass
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
membrane-0.0.2 lib/membrane/schema/class.rb
membrane-0.0.1 lib/membrane/schema/class.rb