<commit_before>angular.module('angular_objectify_resource')

.factory 'aor.ResourceExtension', ->
    #  options is an object:
    #    model:     class
    #    namespace: if response is not an array, gives the key to get data
    get: (options)->

      build_object: (callback)->
        that = @
        (response)->
          resource = that.resource_build_method response
          if angular.isFunction(callback)
            callback resource
          else
            resource

      build_nested_collection: (callback)->
        that = @
        (response)->
          namespace  = options.namespace
          isArray    = angular.isArray(response)
          collection = if isArray then response else response[namespace]
          resources  = _.map collection, that.resource_build_method

          if isArray
            response.splice(0, response.length)
            response =  response.concat resources
          else
            response[namespace] = resources

          if angular.isFunction(callback)
            callback response
          else
            response

      resource_build_method: (resource)->
        new options.model(resource)<commit_msg>let set custom namespace for some methods<commit_after>angular.module('angular_objectify_resource')

.factory 'aor.ResourceExtension', ->
    #  options is an object:
    #    model:     class
    #    namespace: if response is not an array, gives the key to get data
    get: (options)->

      build_object: (callback)->
        that = @
        (response)->
          resource = that.resource_build_method response
          if angular.isFunction(callback)
            callback resource
          else
            resource

      build_nested_collection: (callback, special_options = {})->
        that = @
        (response)->
          namespace  = special_options.namespace || options.namespace
          isArray    = angular.isArray(response)
          collection = if isArray then response else response[namespace]
          resources  = _.map collection, that.resource_build_method

          if isArray
            response.splice(0, response.length)
            response =  response.concat resources
          else
            response[namespace] = resources

          if angular.isFunction(callback)
            callback response
          else
            response

      resource_build_method: (resource)->
        new options.model(resource)
{'fraction_non_alphanumeric': 0.07515400410677618, 'fraction_numerical': 0.0008213552361396304, 'mean_word_length': 1.981640146878825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7323947', 'n_tokens_mistral': 577, 'n_tokens_neox': 568, 'n_words': 159}