<commit_before>class Model
  constructor: (@props = {}) ->
    @setupProps()
    @update @props
    @persisted = @props._id?
    @addDefaults()

    @database = @constructor.database
  
  @attr = (attributes...) ->
    @attributes ||= []

    if typeof(attributes[attributes.length-1]) is "object"
      options = attributes.pop()

      if options.default
        @defaults ||= {}
        attributes.forEach (attribute) =>
          @defaults[attribute] = options.default
    
    @attributes = @attributes.concat(attributes)
  
  @type = (type = false) ->
    @type = type if type
    @type
  
  setupProps: ->
    @_props = {}
    @_dirty = []

    @constructor.attributes.forEach (attr) =>
      @__defineGetter__ attr, =>
        @_props[attr]
      
      @__defineSetter__ attr, (val) =>
        @_props[attr] = val
        @_dirty.push attr
  
  addDefaults: ->
    @update(@constructor.defaults, false) if @constructor.defaults? and not @persisted
  
  update: (props, override = true) ->
    for key, value of props<commit_msg>fixed inheritance bug with default properties<commit_after>_ = require('underscore')

class Model
  constructor: (@props = {}) ->
    @setupProps()
    @update @props
    @persisted = @props._id?
    @addDefaults()

    @database = @constructor.database
  
  @attr = (attributes...) ->
    @attributes ||= []

    if typeof(attributes[attributes.length-1]) is "object"
      options = attributes.pop()

      if options.default
        @defaults ||= {}
        @defaults = _.clone @defaults

        attributes.forEach (attribute) =>
          @defaults[attribute] = options.default
    
    @attributes = _.uniq @attributes.concat(attributes)
  
  @type = (type = false) ->
    @_type = type if type
    @_type
  
  setupProps: ->
    @_props = {}
    @_dirty = []

    @constructor.attributes.forEach (attr) =>
      @__defineGetter__ attr, =>
        @_props[attr]
      
      @__defineSetter__ attr, (val) =>
        @_props[attr] = val
        @_dirty.push attr
  
  addDefaults: ->
    @update(@constructor.defaults, false) if @constructor.defaults? and not @persisted
  
  update: (props, override = true) ->
    for key, value of props
{'fraction_non_alphanumeric': 0.13938560293443375, 'fraction_numerical': 0.0009170105456212746, 'mean_word_length': 2.4856230031948883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '867441', 'n_tokens_mistral': 664, 'n_tokens_neox': 650, 'n_words': 150}