<commit_before># The Experiment Model
#
class Experiment
  include DataMapper::Resource
  
  property :id,          Serial
  property :created_at,  DateTime
  property :update_at,   DateTime
  
  property :name,        String
  property :description, Text
  
  validates_presence_of :name
  
end

# The User Model
# 
class User
  include DataMapper::Resource
  include BCrypt
  
  attr_accessor :password
  
  property :created_at, DateTime
  
  property :id,    Serial
  property :email, String
  property :name,  String
  property :crypted_password, String, :length => 70
  
  validates_uniqueness_of    :email,    :case_sensitive => false
  validates_format_of        :email,    :with => :email_address
  validates_presence_of      :password
  validates_presence_of      :name
  
  ##
  # This method is for authentication purpose
  #
  def self.authenticate(email, password)
    account = first(:conditions => { :email => email })
    account && account.has_password?(password) ? account : nil
  end
  
  def has_password?(password)
    Password.new(crypted_password) == password
  end
  
  # Callbacks
  before :save, :encrypt_password
  
  private
    def encrypt_password
      self.crypted_password = <PASSWORD>(password)
    end
end<commit_msg>Many to many relationship<commit_after># The Experiment Model
#
class Experiment
  include DataMapper::Resource
  
  property :id,          Serial
  property :created_at,  DateTime
  property :update_at,   DateTime
  
  property :name,        String
  property :description, Text
  
  has n, :users, :through => Resource
  
  validates_presence_of :name
  
end

# The User Model
# 
class User
  include DataMapper::Resource
  include BCrypt
  
  attr_accessor :password
  
  property :created_at, DateTime
  
  property :id,    Serial
  property :email, String
  property :name,  String
  property :crypted_password, String, :length => 70
  
  has n, :experiments, :through => Resource
  
  validates_uniqueness_of    :email,    :case_sensitive => false
  validates_format_of        :email,    :with => :email_address
  validates_presence_of      :password
  validates_presence_of      :name
  
  ##
  # This method is for authentication purpose
  #
  def self.authenticate(email, password)
    account = first(:conditions => { :email => email })
    account && account.has_password?(password) ? account : nil
  end
  
  def has_password?(password)
    Password.new(crypted_password) == password
  end
  
  # Callbacks
  before :save, :encrypt_password
  
  private
    def encrypt_password
      self.crypted_password = Password.create(password)
    end
end
{'fraction_non_alphanumeric': 0.07698199923400996, 'fraction_numerical': 0.0015319800842589046, 'mean_word_length': 3.2471544715447154, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, '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': '5055057', 'n_tokens_mistral': 806, 'n_tokens_neox': 792, 'n_words': 212}