<commit_before>module RoleModel
  module Implementation

    # assign roles
    def roles=(*roles)
      self.send("#{self.class.roles_attribute_name}=", (Array[*roles].flatten.map { |r| r.to_sym } & self.class.valid_roles).map { |r| 2**self.class.valid_roles.index(r) }.inject { |sum, bitvalue| sum + bitvalue })
    end

    # query assigned roles
    def roles
      Roles.new(self, self.class.valid_roles.reject { |r| ((self.send(self.class.roles_attribute_name) || 0) & 2**self.class.valid_roles.index(r)).zero? })
    end
    alias_method :role_symbols, :roles

    # check if a given role has been assigned 
    # if a list of roles: check if ALL of the given roles have been assigned 
    def has_roles?(*roles)
      (roles.to_a - roles.flatten).empty?      
    end
    alias_method :is?, :has_roles?
    # alias_method :have_roles?, :has_roles?
    
    # check if any (at least ONE) of the given roles have been assigned
    def has_role? *roles
      !(roles.flatten & self.class.valid_roles).empty?            
    end
    alias_method :has?, :has_role?
    # alias_method :have_role?, :has_role?

  end
end<commit_msg>whitespace and punctuation<commit_after>module RoleModel
  module Implementation

    # assign roles
    def roles=(*roles)
      self.send("#{self.class.roles_attribute_name}=", (Array[*roles].flatten.map { |r| r.to_sym } & self.class.valid_roles).map { |r| 2**self.class.valid_roles.index(r) }.inject { |sum, bitvalue| sum + bitvalue })
    end

    # query assigned roles
    def roles
      Roles.new(self, self.class.valid_roles.reject { |r| ((self.send(self.class.roles_attribute_name) || 0) & 2**self.class.valid_roles.index(r)).zero? })
    end
    alias_method :role_symbols, :roles

    # check if a given role has been assigned 
    # if a list of roles: check if ALL of the given roles have been assigned 
    def has_roles?(*roles)
      (roles.to_a - roles.flatten).empty?
    end
    alias_method :is?, :has_roles?

    # check if any (at least ONE) of the given roles have been assigned
    def has_role?(*roles)
      !(roles.flatten & self.class.valid_roles).empty?
    end
    alias_method :has?, :has_role?

  end
end
{'fraction_non_alphanumeric': 0.12442396313364056, 'fraction_numerical': 0.0027649769585253456, 'mean_word_length': 3.1911196911196913, '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': '4418311', 'n_tokens_mistral': 766, 'n_tokens_neox': 744, 'n_words': 188}