 
   to_html: () ->
     to = @constructor.to
-    self = @
-    result = for key, attrs of to
-      value = self.get(key)
+    for key, attrs of to
+      value = @get(key)
       tag = attrs["tag"] || "div"
-      delete attrs["tag"]
-      SiriusApplication.adapter.element(tag, value, attrs)
-    result
+      clone = {}
+      for key, v of attrs when key isnt "tag" then clone[key] = v
+
+      SiriusApplication.adapter.element(tag, value, clone)
 
   @from_json: (json = {}) ->
     m = new @


    for attr in @attributes
      do(attr) ->
        z["#{attr}"] = self.get("#{attr}")

    if root
      o = {}

    @attrs: ["name"]
    has_one: Person

has_one, has_many must take arrays with models

belongs_to must take a array with objects as { :model => modelName[String] } with optional
  argument a foreign key :

  belongs_to { model => "person", :back => "name" }
  generate next methods:
    model_back ~> person_name

  if a belongs_to not present must be a throw exception



###

class BaseModel

  attrs: () ->
    @constructor.attrs || []

  #normalize model name: UserModel => user_model
  normal_name: () ->
    @constructor.name.replace(/([A-Z])/g, '_$1').replace(/^_/,"").toLowerCase()

