Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set dump_as explicitly on all properties

  • Loading branch information...
commit f3b53616c8e656eac23096378024f337face8888 1 parent 4999726
@solnic solnic authored
View
7 lib/dm-core/property.rb
@@ -446,8 +446,9 @@ def options
end
# @api deprecated
- def primitive
- load_as
+ def primitive(*args)
+ warn "DataMapper::Property.primitive is deprecated, use .load_as instead (#{caller.first})"
+ load_as(*args)
end
end
@@ -753,7 +754,7 @@ def initialize(model, name, options = {})
@coercion_method = @options.fetch(:coercion_method)
@load_as = self.class.load_as
- @dump_as = @options.fetch(:dump_as, @load_as)
+ @dump_as = self.class.dump_as
@field = @options[:field].freeze unless @options[:field].nil?
@default = @options[:default]
View
1  lib/dm-core/property/boolean.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Boolean < Object
load_as ::TrueClass
+ dump_as ::TrueClass
coercion_method :to_boolean
# @api semipublic
View
1  lib/dm-core/property/class.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Class < Object
load_as ::Class
+ dump_as ::Class
coercion_method :to_constant
# @api semipublic
View
1  lib/dm-core/property/date.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Date < Object
load_as ::Date
+ dump_as ::Date
coercion_method :to_date
end # class Date
View
1  lib/dm-core/property/date_time.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class DateTime < Object
load_as ::DateTime
+ dump_as ::DateTime
coercion_method :to_datetime
end # class DateTime
View
1  lib/dm-core/property/decimal.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Decimal < Numeric
load_as BigDecimal
+ dump_as BigDecimal
coercion_method :to_decimal
DEFAULT_PRECISION = 10
View
1  lib/dm-core/property/float.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Float < Numeric
load_as ::Float
+ dump_as ::Float
coercion_method :to_float
DEFAULT_PRECISION = 10
View
1  lib/dm-core/property/integer.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Integer < Numeric
load_as ::Integer
+ dump_as ::Integer
coercion_method :to_integer
accept_options :serial
View
1  lib/dm-core/property/object.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Object < Property
load_as ::Object
+ dump_as ::Object
coercion_method :to_object
# @api semipublic
View
1  lib/dm-core/property/string.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class String < Object
load_as ::String
+ dump_as ::String
coercion_method :to_string
accept_options :length
View
1  lib/dm-core/property/time.rb
@@ -2,6 +2,7 @@ module DataMapper
class Property
class Time < Object
load_as ::Time
+ dump_as ::Time
coercion_method :to_time
end # class Time
View
2  spec/public/property/binary_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_string, :length => 50) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_string, :length => 50) }
end
end
View
2  spec/public/property/boolean_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_boolean) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_boolean) }
end
end
View
2  spec/public/property/class_spec.rb
@@ -23,6 +23,6 @@ class ::Bar; end
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_constant) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_constant) }
end
end
View
2  spec/public/property/date_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_date) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_date) }
end
end
View
2  spec/public/property/date_time_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_datetime) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_datetime) }
end
end
View
2  spec/public/property/decimal_spec.rb
@@ -18,6 +18,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_decimal, :precision => 10, :scale => 0) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_decimal, :precision => 10, :scale => 0) }
end
end
View
2  spec/public/property/float_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_float, :precision => 10, :scale => nil) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_float, :precision => 10, :scale => nil) }
end
end
View
2  spec/public/property/integer_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_integer) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_integer) }
end
end
View
2  spec/public/property/serial_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_integer, :min => 1, :serial => true) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_integer, :min => 1, :serial => true) }
end
end
View
2  spec/public/property/string_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_string, :length => 50) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_string, :length => 50) }
end
end
View
2  spec/public/property/text_spec.rb
@@ -17,7 +17,7 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_string, :length => 65535, :lazy => true) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_string, :length => 65535, :lazy => true) }
end
describe 'migration with an index' do
View
2  spec/public/property/time_spec.rb
@@ -17,6 +17,6 @@
it { should be_kind_of(Hash) }
- it { should eql(:load_as => @load_as, :coercion_method => :to_time) }
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_time) }
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.