Module: GoldenFleece::Context::Schemas

Included in:
GoldenFleece::Context
Defined in:
lib/golden_fleece/context/schemas.rb

Instance Method Summary collapse

Instance Method Details

#define_schemas(attribute, schema_definitions = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/golden_fleece/context/schemas.rb', line 4

def define_schemas(attribute, schema_definitions = {})
  attribute_schema = schemas[attribute.to_sym]

  # Allow redefining individual schemas
  if attribute_schema
    schema_definitions.each do |schema_name, schema_definition|
      schemas[attribute.to_sym][schema_name.to_sym] = schema_definition
    end
  else
    schemas[attribute.to_sym] = schema_definitions
  end

  attributes << attribute unless attributes.include? attribute
end