Permalink
Browse files

Some fixes

  • Loading branch information...
pnomolos committed Aug 24, 2012
1 parent 0c6c2ae commit 292f40866e11874995cc6a6c585e039190887057
Showing with 1 addition and 48 deletions.
  1. +1 −2 lib/dm-types-serialized-php.rb
  2. +0 −46 lib/dm-types-serialized-php/serialized-php.rb
@@ -1,8 +1,7 @@
require 'dm-core'
-require 'dm-types-serialized-php/version'
module DataMapper
class Property
- autoload :SerializedPhp, 'dm-types-serialized-php/serialized-php'
+ autoload :SerializedPhp, 'dm-types-serialized-php/serialized_php'
end
end
@@ -1,46 +0,0 @@
-require 'dm-core'
-require 'dm-types/support/dirty_minder'
-require 'php_serialize'
-
-module DataMapper
- class Property
- class SerializedPhp < Text
- def custom?
- true
- end
-
- def primitive?(value)
- !::PHP.serialized?(value)
- end
-
- def valid?(value, negated = false)
- super || dump(value).kind_of?(::String)
- end
-
- def load(value)
- if value.nil?
- nil
- elsif value.is_a?(::String)
- typecast_to_primitive(value)
- else
- raise ArgumentError.new("+value+ of a property of SerializedPhp type must be nil or a String")
- end
- end
-
- def dump(value)
- if value.nil? || (value.is_a?(::String) && !::Php.serialized?(value))
- value
- else
- ::PHP.serialize(value)
- end
- end
-
- def typecast_to_primitive(value)
- ::PHP.unserialize(value.to_s)
- end
-
- include ::DataMapper::Property::DirtyMinder
-
- end # class SerializedPhp
- end # class Property
-end # module DataMapper

0 comments on commit 292f408

Please sign in to comment.