Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

store config data in metadata for custom classes.

  • Loading branch information...
commit 4bf44de1552d930ab4eeb504121b2ef8ba6fd6e5 1 parent 1945393
@robey authored
Showing with 12 additions and 0 deletions.
  1. +4 −0 src/fauna/schema.coffee
  2. +8 −0 test/test_schema.coffee
View
4 src/fauna/schema.coffee
@@ -31,6 +31,9 @@ class Class
@native = ->
metadataForClass(@).native = true
+ @data = (data) ->
+ metadataForClass(@).data = data
+
exports.Class = Class
@@ -39,6 +42,7 @@ class ClassMetadata
constructor: (@jsClass) ->
@className = null
@native = false
+ @data = {}
@schema = {}
@eventSets = []
View
8 test/test_schema.coffee
@@ -97,6 +97,14 @@ describe "Schema", ->
s.metadataForClassName("cats").native.should.eql(false)
s.metadataForClassName("users").native.should.eql(true)
+ it "can store config data", ->
+ class Cat extends fauna.Class
+ @field "name"
+ @data whiskers: true, lives: 9
+ s = new fauna.Schema()
+ s.addPrototypes Cat
+ s.metadataForClassName("cats").data.should.eql { whiskers: true, lives: 9 }
+
describe "EventSet", ->
it "can flatten events to an array", ->
Please sign in to comment.
Something went wrong with that request. Please try again.