fix mongoid and mongo_mapper incompabilities
This commit is contained in:
parent
0263f9e663
commit
e3d46024a4
|
@ -10,8 +10,7 @@ module Impressionist
|
||||||
end
|
end
|
||||||
|
|
||||||
initializer 'impressionist.model' do |app|
|
initializer 'impressionist.model' do |app|
|
||||||
require_orm
|
require_and_include_orm
|
||||||
ActiveRecord::Base.send(:include, Impressionist::Impressionable)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ module Impressionist
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def require_orm
|
def require_and_include_orm
|
||||||
require "#{root}/app/models/impressionist/impressionable.rb"
|
require "#{root}/app/models/impressionist/impressionable.rb"
|
||||||
require "impressionist/models/#{orm}/impression.rb"
|
require "impressionist/models/#{orm}/impression.rb"
|
||||||
require "impressionist/models/#{orm}/impressionist/impressionable.rb"
|
require "impressionist/models/#{orm}/impressionist/impressionable.rb"
|
||||||
|
@ -38,10 +37,10 @@ module Impressionist
|
||||||
@orm = matcher(str.to_s)
|
@orm = matcher(str.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def matcher(str)
|
def matcher(str)
|
||||||
matched = str.match(/active_record|mongo_mapper|mongoid|/)
|
matched = str.match(/active_record|mongo_mapper|mongoid|/)
|
||||||
matched[0]
|
matched[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
ActiveRecord::Base.send(:include, Impressionist::Impressionable)
|
||||||
|
|
||||||
module Impressionist
|
module Impressionist
|
||||||
module Impressionable
|
module Impressionable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
MongoMapper::Document.plugin Impressionist::Impressionable
|
||||||
|
|
||||||
module Impressionist
|
module Impressionist
|
||||||
module Impressionable
|
module Impressionable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
Mongoid::Document.send(:include, Impressionist::Impressionable)
|
||||||
|
|
||||||
module Impressionist
|
module Impressionist
|
||||||
module Impressionable
|
module Impressionable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
Loading…
Reference in New Issue