Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bare embedded/virtual properties

  • Loading branch information...
commit d1ef20a6c00b3f0b4e40e2b8c2381f7824417c12 1 parent 807d15f
@collin authored
View
7 lib/alpha_simprini/core/properties/embeds_many.coffee
@@ -0,0 +1,7 @@
+AS = require "alpha_simprini"
+
+AS.Model.EmbedsMany = AS.Model.HasMany.extend()
+AS.Model.EmbedsMany.Instance = AS.Model.HasMany.Instance.extend ({def, delegate}) ->
+
+AS.Model.defs embedsMany: (name, options) ->
+ AS.Model.EmbedsMany.new(name, this, options)
View
7 lib/alpha_simprini/core/properties/embeds_one.coffee
@@ -0,0 +1,7 @@
+AS = require "alpha_simprini"
+
+AS.Model.EmbedsOne = AS.Model.HasOne.extend()
+AS.Model.EmbedsOne.Instance = AS.Model.HasOne.Instance.extend ({def, delegate}) ->
+
+AS.Model.defs embedsOne: (name, options) ->
+ AS.Model.EmbedsOne.new(name, this, options)
View
9 lib/alpha_simprini/core/properties/virtual_properties.coffee
@@ -0,0 +1,9 @@
+AS = require("alpha_simprini")
+
+AS.Model.VirtualProperty = AS.Property.extend ({def}) ->
+
+AS.Model.VirtualProperty.Instance = AS.Property.Instance.extend ({def}) ->
+
+AS.Model.defs virtualProperties: (dependencies..., properties) ->
+ for name, fn of properties
+ AS.Model.VirtualProperty.new(name, this, dependencies: dependencies, fn: fn)
View
20 test/core/properties/embeds_many.coffee
@@ -0,0 +1,20 @@
+helper = require require("path").resolve("./test/helper")
+{AS, _, sinon, coreSetUp, RelationModel, FieldModel, NS} = helper
+exports.setUp = coreSetUp
+
+NS.Parent = AS.Model.extend()
+NS.Parent.embedsMany "embeds"
+
+# NS.Child = NS.Parent.extend()
+# NS.Child.hasMany "children", model: -> NS.Child
+
+exports.EmbedsMany =
+ "property is a HasMany": (test) ->
+ o = NS.Parent.new()
+ test.ok o.embeds instanceof AS.Model.HasMany.Instance
+ test.done()
+
+ "property is an EmbedsMany": (test) ->
+ o = NS.Parent.new()
+ test.ok o.embeds instanceof AS.Model.EmbedsMany.Instance
+ test.done()
View
20 test/core/properties/embeds_one.coffee
@@ -0,0 +1,20 @@
+helper = require require("path").resolve("./test/helper")
+{AS, _, sinon, coreSetUp, RelationModel, FieldModel, NS} = helper
+exports.setUp = coreSetUp
+
+NS.Parent = AS.Model.extend()
+NS.Parent.embedsOne "embed"
+
+# NS.Child = NS.Parent.extend()
+# NS.Child.hasMany "children", model: -> NS.Child
+
+exports.EmbedsMany =
+ "property is a HasOne": (test) ->
+ o = NS.Parent.new()
+ test.ok o.embed instanceof AS.Model.HasOne.Instance
+ test.done()
+
+ "property is an EmbedsOne": (test) ->
+ o = NS.Parent.new()
+ test.ok o.embed instanceof AS.Model.EmbedsOne.Instance
+ test.done()
View
16 test/core/properties/virtual_property.coffee
@@ -0,0 +1,16 @@
+helper = require require("path").resolve("./test/helper")
+{AS, _, sinon, coreSetUp, RelationModel, FieldModel, NS} = helper
+exports.setUp = coreSetUp
+
+
+NS.Virtualized = AS.Model.extend ->
+ @field "name"
+ @virtualProperties "name",
+ virtualA: ->
+ virtualB: ->
+
+exports.VirtualProperty =
+ "is a virtual": (test) ->
+ test.ok NS.Virtualized.properties.virtualA instanceof AS.Model.VirtualProperty
+ test.ok NS.Virtualized.properties.virtualB instanceof AS.Model.VirtualProperty
+ test.done()
Please sign in to comment.
Something went wrong with that request. Please try again.