Class: SimpleSchema::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_schema/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defined_schema, options = {}) ⇒ Schema

Returns a new instance of Schema.

Raises:



5
6
7
8
9
10
11
# File 'lib/simple_schema/schema.rb', line 5

def initialize(defined_schema, options = {})
  options[:normalizers] ||= [SchemaItems, SchemaProperties]
  options[:defaults] ||= {:required => true, :type => :string}
  raise InvalidSchemaType.new(defined_schema.class) unless defined_schema.is_a?(Hash) || defined_schema.is_a?(Array)
  @options = options
  @schema = normalize(defined_schema)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/simple_schema/schema.rb', line 3

def options
  @options
end

#schemaObject (readonly)

Returns the value of attribute schema.



3
4
5
# File 'lib/simple_schema/schema.rb', line 3

def schema
  @schema
end