Remove column and replace it with custom method

How to remove a column from the database and replace the column with a custom method so that I no need to change all the legacy code that is using the old column?

# Book.rb
# column available removed from the database

def available?
  # add custom available method here
  # will return true/false
end

The above code is fine and can be accessed with something like this, Book.first.available?. The question here is how to not change the query statement Book.where(available: true) but still get the same result? Is there a way to create a custom rails method and can be apply in query?


From what I understood, I think this could work

def available_books
  all_available_books = Book.all
  all_available_books.select! { |book| book.available? }
end

def not_available_books
  all_not_available_books = Book.all
  all_not_available_books.select! { |book| !book.available? }
end