<commit_before>module ViewModels
  module Helpers
    module Rails
      
      # Construct a view_model for a collection.
      #
      def collection_view_model_for array_or_pagination, context = self
        Collection.new array_or_pagination, context
      end
      
      # The Collection view_model helper has the purpose of presenting presentable collections.
      # * Render as list
      # * Render as table
      # * Render as collection
      # * Render a pagination
      #
      class Collection
        
        #
        #
        methods_to_delegate = [Enumerable.instance_methods.map(&:to_sym),
                               :length, :size, :empty?, :each, :exit,
                               { :to => :@collection }].flatten
        self.delegate *methods_to_delegate
        def select *args, &block # active_support fail?
          @collection.select *args, &block
        end
        
        def initialize collection, context
          @collection, @context = collection, context
        end
        
        # Renders a list (in the broadest sense of the word).
        #
        # Options:
        #   collection => collection to iterate over
        #   context => context to render in
        #   template_name => template to render for each model element
        #   separator => separator between each element
        # By default, uses:
        #   * The collection of the collection view_model to iterate over.
        #   * The original context given to the collection view_model to render in.
        #   * Uses :list_item as the default element template.
        #   * Uses a nil separator in html.<commit_msg>- superfluous method, + delegation specification<commit_after>module ViewModels
  module Helpers
    module Rails
      
      # Construct a view_model for a collection.
      #
      # TODO Think about moving it into view_model_for, or renaming it view_models_for.
      #
      def collection_view_model_for array_or_pagination, context = self
        Collection.new array_or_pagination, context
      end
      
      # The Collection view_model helper has the purpose of presenting presentable collections.
      # * Render as list
      # * Render as table
      # * Render as collection
      # * Render a pagination
      #
      class Collection
        
        # Delegate collection relevant methods to the collection.
        #
        self.delegate *[Enumerable.instance_methods, :length, :size, :empty?, :each, :exit, { :to => :@collection }].flatten
        
        #
        #
        def initialize collection, context
          @collection, @context = collection, context
        end
        
        # Renders a list (in the broadest sense of the word).
        #
        # Options:
        #   collection => collection to iterate over
        #   context => context to render in
        #   template_name => template to render for each model element
        #   separator => separator between each element
        # By default, uses:
        #   * The collection of the collection view_model to iterate over.
        #   * The original context given to the collection view_model to render in.
        #   * Uses :list_item as the default element template.
        #   * Uses a nil separator in html.
{'fraction_non_alphanumeric': 0.06242350061199511, 'fraction_numerical': 0.0, 'mean_word_length': 1.9637352674524025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '781858', 'n_tokens_mistral': 811, 'n_tokens_neox': 801, 'n_words': 303}