You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: has_bit_flags.rb
    path of file: ./repos/danbooru/app/logical/concerns
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module HasBitFlags
  extend ActiveSupport::Concern

  # NOTE: the ordering of attributes has to be fixed#
  # new attributes should be appended to the end.
  def has_bit_flags(attributes, field: :bit_flags)
    
  def has_bit_flags(attributes, field: :bit_flags)
    attributes.each.with_index do |attribute, i|
      bit_flag = 1 << i
      field_was = "#{field}_was"

      define_method(attribute) do
        send(field) & bit_flag > 0
      end

      define_method("#{attribute}?") do
        send(field) & bit_flag > 0
      end

      define_method("#{attribute}_was") do
        send(field_was) & bit_flag > 0
      end

      define_method("#{attribute}_was?") do
        send(field_was) & bit_flag > 0
      end

      define_method("#{attribute}=") do |val|
        if val.to_s =~ /[t1y]/
          send("#{field}=", send(field) | bit_flag)
        else
          send("#{field}=", send(field) & ~bit_flag)
        end
      end
    end