module Surrealist::SchemaDefiner
A class that defines a method on the object that stores the schema.
Constants
- SCHEMA_TYPE_ERROR
Public Class Methods
call(klass, hash)
click to toggle source
Defines an instance variable on the object that stores the schema.
@param [Object] klass class of the object that needs to be surrealized.
@param [Hash] hash the schema defined in the object's class.
@return [Hash] +@__surrealist_schema+ variable that stores the schema of the object.
@raise Surrealist::InvalidSchemaError
if schema was defined not through a hash.
# File lib/surrealist/schema_definer.rb, line 18 def call(klass, hash) raise Surrealist::InvalidSchemaError, SCHEMA_TYPE_ERROR unless hash.is_a?(Hash) Surrealist::VarsHelper.set_schema(klass, hash) end