Permalink
Browse files

make the "copied" class work without deprecated message for all DM ve…

…rsions
  • Loading branch information...
1 parent ba03010 commit ebbb019b0a5b5e8b1fc242aee91b8c9e16930a42 @mkristian committed Dec 4, 2011
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/ldap_resource.rb
View
@@ -4,7 +4,15 @@
module DataMapper
module Model
-
+
+ if DataMapper::VERSION =~ /^1.[0-1]/
+ Immutable = Resource::State::Immutable
+ Clean = Resource::State::Clean
+ else
+ Immutable = Resource::PersistenceState::Immutable
+ Clean = Resource::PersistenceState::Clean
+ end
+
def load(records, query)
repository = query.repository
repository_name = repository.name
@@ -67,13 +75,17 @@ def load(records, query)
resource.instance_variable_set(:@_repository, repository)
if identity_map
- resource.persistence_state = Resource::PersistenceState::Clean.new(resource) unless resource.persistence_state?
-
+ if DataMapper::VERSION =~ /^1.[0-1]/
+ resource.persisted_state = Clean.new(resource) unless resource.persisted_state?
+ else
+ resource.persistence_state = Clean.new(resource) unless resource.persistence_state?
+ end
+
# defer setting the IdentityMap so second level caches can
# record the state of the resource after loaded
identity_map[key_values] = resource
else
- resource.persisted_state = Resource::State::Immutable.new(resource)
+ resource.persisted_state = Immutable.new(resource)
end
resource

0 comments on commit ebbb019

Please sign in to comment.