       this.hasChanges = false
     resourceUrl: ()->
       "/metrics/#{self.id}"
-    params: ()-> {
-      name: this.name,
-      max_points: this.max_points,
-      order: this.order(),
-      description: this.description,
-      rubric_id: this.rubricId
-    }
     order: ()->
       jQuery.inArray(this, $scope.metrics)
+    params: ()->
+      self = this
+      {
+        name: self.name,
+        max_points: self.max_points,
+        order: self.order(),
+        description: self.description,
+        rubric_id: self.rubricId
+      }
     index: ()->
       this.order()
     destroy: ()->

    $scope.savedMetricCount += 1

  MetricPrototype = (attrs={})->
#    this.tiers = []
#    # this.addTiers(attrs["tiers"]) if attrs["tiers"] #add tiers if passed on init
#    this.id = if attrs.id then attrs.id else null
#    this.name = if attrs.name then attrs.name else ""
#    this.rubricId = if attrs.rubric_id then attrs.rubric_id else $scope.rubricId
#    this.max_points = if attrs.max_points then attrs.max_points else null
#    this.description = if attrs.description then attrs.description else ""
#    this.hasChanges = false
  MetricPrototype.prototype =
    addTier: (attrs={})->
      self = this
      newTier = new TierPrototype(self, attrs)
      this.tiers.push newTier
    isNew: ()->
      this.id is null
    isSaved: ()->

  $scope.savedMetricCount = 0

  $scope.init = (rubricId, metrics)->
    $scope.rubricId = rubricId
    $scope.addMetrics(metrics)

