onyxframework / sql

A delightful SQL ORM ☺️
https://api.onyxframework.com/sql
MIT License
91 stars 7 forks source link

Add `.table` method to models #89

Closed vladfaust closed 5 years ago

vladfaust commented 5 years ago

This is tricky, because table is defined in class-level annotation like this:

@[Onyx::SQL::Model::Options(table: "users")]
class User
end

One option is to make Model.schema macro define .table class method.

vladfaust commented 5 years ago

This works, though :sweat_smile:

class User
  def table
    "users"
  end
end

user = uninitialized User
pp user.table