<commit_before># frozen_string_literal: true

module Nylas
  # An enumerable for working with index and search endpoints
  class Collection
    attr_accessor :model, :api, :constraints

    extend Forwardable
    def_delegators :each, :map, :select, :reject, :to_a, :take
    def_delegators :to_a, :first, :last, :[]

    def initialize(model:, api:, constraints: nil)
      self.constraints = Constraints.from_constraints(constraints)
      self.model = model
      self.api = api
    end

    # Instantiates a new model
    def new(**attributes)
      model.new(attributes.merge(api: api))
    end

    def create(**attributes)
      instance = model.new(**attributes.merge(api: api))
      instance.save
      instance
    end
<commit_msg>fix Collection new method to expand keyword args (#379)<commit_after># frozen_string_literal: true

module Nylas
  # An enumerable for working with index and search endpoints
  class Collection
    attr_accessor :model, :api, :constraints

    extend Forwardable
    def_delegators :each, :map, :select, :reject, :to_a, :take
    def_delegators :to_a, :first, :last, :[]

    def initialize(model:, api:, constraints: nil)
      self.constraints = Constraints.from_constraints(constraints)
      self.model = model
      self.api = api
    end

    # Instantiates a new model
    def new(**attributes)
      model.new(**attributes.merge(api: api))
    end

    def create(**attributes)
      instance = model.new(**attributes.merge(api: api))
      instance.save
      instance
    end

{'fraction_non_alphanumeric': 0.10013089005235602, 'fraction_numerical': 0.001963350785340314, 'mean_word_length': 3.307042253521127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3271815', 'n_tokens_mistral': 475, 'n_tokens_neox': 453, 'n_words': 132}