Du kan definiera de vanliga attributen i en modul och inkludera det.
require 'mongoid'
module DefaultAttrs
def self.included(klass)
klass.instance_eval do
field :uuid, :type => String
end
end
end
class Foo
include Mongoid::Document
include DefaultAttrs
field :a, :type => String
end
class Bar
include Mongoid::Document
include DefaultAttrs
field :b, :type => String
end