I was hoping to use Sequel's `class_table_inheritance` plugin as a simple
strategy for authorization:
require 'sequel'
DB = Sequel.sqlite
DB.create_table(:users) do
primary_key :id
String :type
String :name, null: false, unique: true
end
class User < Sequel::Model
plugin :class_table_inheritance, key: :type
end
class Moderator < User; end
class Administrator < Moderator; end
I know I can modify the User-instance's `type` to change the role, but is
there a way to simply cast the instance as a new type to accomplish this?
IRB> u = Moderator.create(name:'craig')
=> #<Moderator @values={:id=>4, :type=>"User", :name=>"craig"}>
IRB> Administrator(u)
NoMethodError (undefined method `Administrator' for main:Object)
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.