lib/golden_fleece/context/schemas.rb in golden_fleece-0.1.1 vs lib/golden_fleece/context/schemas.rb in golden_fleece-0.1.2
- old
+ new
@@ -1,10 +1,20 @@
module GoldenFleece
class Context
module Schemas
def define_schemas(attribute, schema_definitions = {})
- schemas[attribute.to_sym] ||= schema_definitions
- attributes << attribute
+ 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
end
end
end