 
       SiriusApplication.adapter.element(tag, value, clone)
 
+  # Create a new model instance from json structure.
+  # @note not support a relations
+  #
   @from_json: (json = {}) ->
     m = new @
     json = JSON.parse(json)

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

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

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

  belongs_to: () ->
    @constructor.belongs_to || [] #array with object

  validators: () ->
    @constructor.validate

  #
  normalize_attrs: () ->
    for a in @constructor.attrs
      do(a) ->

        do(attr) ->
          self.set(attr, obj[attr])

  # base setter
  # @throw Error, when attributes not defined for current model
  set: (attr, value) ->
    throw new Error("Attribute '#{attr}' not found for #{@normal_name().toUpperCase()} model") if @attributes.indexOf(attr) == -1

    # TODO validate value
    @["_#{attr}"] = value

  # base getter
  # @throw Error, when attributes not defined for current model
  get: (attr) ->
    throw new Error("Attribute '#{attr}' not found for #{@normal_name().toUpperCase()} model") if @attributes.indexOf(attr) == -1

    @["_#{attr}"]

  # @return [Boolean] check if current model instance is valid
  valid: () ->
    @_isValid

  # @nodoc
  validate: () ->
    @errors = {}
    vv = @validators()
