Created
June 7, 2011 07:01
-
-
Save shirkevich/1011798 to your computer and use it in GitHub Desktop.
mongoid shouldn't extend core Object class (using mongoid with sequel)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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