<commit_before>Nali.extend Collection:

  toShowViews:  []
  visibleViews: []
  length:       0

  cloning: ->
    @subscribeTo @Model, "create.#{ @model._name.lower() }", @onModelCreated
    @subscribeTo @Model, "update.#{ @model._name.lower() }", @onModelUpdated
    @adaptations = apply: [], cancel: []
    @ordering    = {}
    @adaptCollection()
    @

  new: ( model, filters ) ->
    @clone model: model, filters: filters

  onModelCreated: ( extModel, model ) ->
    @add model if not @freezed and model.isCorrect @filters
    @

  onModelUpdated: ( extModel, model ) ->
    if model.written()
      if model in @
        if @freezed or model.isCorrect @filters
          @reorder()
          @trigger 'update.model', model
        else @remove model
      else if not @freezed and model.isCorrect @filters
        @add model
    @

  onModelDestroyed: ( model ) ->
    @remove model unless @freezed
    @

  adaptCollection: ->
    for name, method of @model when /^_\w+$/.test( name ) and typeof method is 'function'
      do ( name, method ) =><commit_msg>auto add models when cloning collection<commit_after>Nali.extend Collection:

  toShowViews:  []
  visibleViews: []
  length:       0

  cloning: ->
    @subscribeTo @Model, "create.#{ @model._name.lower() }", @onModelCreated
    @subscribeTo @Model, "update.#{ @model._name.lower() }", @onModelUpdated
    @adaptations = apply: [], cancel: []
    @ordering    = {}
    @adaptCollection()
    @model.each ( model ) => @add model if model.isCorrect @filters
    @

  new: ( model, filters ) ->
    @clone model: model, filters: filters

  onModelCreated: ( extModel, model ) ->
    @add model if not @freezed and model.isCorrect @filters
    @

  onModelUpdated: ( extModel, model ) ->
    if model.written()
      if model in @
        if @freezed or model.isCorrect @filters
          @reorder()
          @trigger 'update.model', model
        else @remove model
      else if not @freezed and model.isCorrect @filters
        @add model
    @

  onModelDestroyed: ( model ) ->
    @remove model unless @freezed
    @

  adaptCollection: ->
    for name, method of @model when /^_\w+$/.test( name ) and typeof method is 'function'
      do ( name, method ) =>
{'fraction_non_alphanumeric': 0.1306104129263914, 'fraction_numerical': 0.0008976660682226212, 'mean_word_length': 2.5951612903225807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '2360662', 'n_tokens_mistral': 698, 'n_tokens_neox': 671, 'n_words': 198}