Merge pull request #81 from nbit001/fix_incompabilities

Fix mongoid and mongo_mapper incompabilities.
This commit is contained in:
Nalesso Moreira 2013-05-15 15:25:47 -07:00
commit 3c2f789306
4 changed files with 10 additions and 5 deletions

View File

@ -10,8 +10,7 @@ module Impressionist
end
initializer 'impressionist.model' do |app|
require_orm
ActiveRecord::Base.send(:include, Impressionist::Impressionable)
require_and_include_orm
end
@ -27,7 +26,7 @@ module Impressionist
private
def require_orm
def require_and_include_orm
require "#{root}/app/models/impressionist/impressionable.rb"
require "impressionist/models/#{orm}/impression.rb"
require "impressionist/models/#{orm}/impressionist/impressionable.rb"
@ -38,10 +37,10 @@ module Impressionist
@orm = matcher(str.to_s)
end
def matcher(str)
def matcher(str)
matched = str.match(/active_record|mongo_mapper|mongoid|/)
matched[0]
end
end
end

View File

@ -1,3 +1,5 @@
ActiveRecord::Base.send(:include, Impressionist::Impressionable)
module Impressionist
module Impressionable
extend ActiveSupport::Concern

View File

@ -1,3 +1,5 @@
MongoMapper::Document.plugin Impressionist::Impressionable
module Impressionist
module Impressionable
extend ActiveSupport::Concern

View File

@ -1,3 +1,5 @@
Mongoid::Document.send(:include, Impressionist::Impressionable)
module Impressionist
module Impressionable
extend ActiveSupport::Concern