Skip to content

Instantly share code, notes, and snippets.

@shirkevich
Created June 7, 2011 07:01
Show Gist options
  • Save shirkevich/1011798 to your computer and use it in GitHub Desktop.
Save shirkevich/1011798 to your computer and use it in GitHub Desktop.
mongoid shouldn't extend core Object class (using mongoid with sequel)
require 'rubygems'
require "sequel"
require "active_support"
# * mongoid (2.0.2)
# * sequel (3.24.1)
module Mongoid #:nodoc:
module Extensions #:nodoc:
module Object #:nodoc:
# This module converts objects into mongoid related objects.
module Conversions #:nodoc:
extend ActiveSupport::Concern
module ClassMethods
def set(value)
value.respond_to?(:attributes) ? value.attributes : value
end
def get(value)
if value && respond_to?(:instantiate)
instantiate(value)
else
value
end
end
end
end
end
end
end
class Object
include Mongoid::Extensions::Object::Conversions
end
module Sequel
module Plugins
module Dumb
end
end
end
Sequel::Model.plugin :dumb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment