Parent

Included Modules

DataMapper::Property::Json

Public Instance Methods

custom?() click to toggle source
    # File lib/dm-types/json.rb, line 9
 9:       def custom?
10:         true
11:       end
dump(value) click to toggle source
    # File lib/dm-types/json.rb, line 31
31:       def dump(value)
32:         if value.nil? || value.is_a?(::String)
33:           value
34:         else
35:           MultiJson.encode(value)
36:         end
37:       end
load(value) click to toggle source
    # File lib/dm-types/json.rb, line 21
21:       def load(value)
22:         if value.nil?
23:           nil
24:         elsif value.is_a?(::String)
25:           typecast_to_primitive(value)
26:         else
27:           raise ArgumentError.new("+value+ of a property of JSON type must be nil or a String")
28:         end
29:       end
primitive?(value) click to toggle source
    # File lib/dm-types/json.rb, line 13
13:       def primitive?(value)
14:         value.kind_of?(::Array) || value.kind_of?(::Hash)
15:       end
typecast_to_primitive(value) click to toggle source
    # File lib/dm-types/json.rb, line 39
39:       def typecast_to_primitive(value)
40:         MultiJson.decode(value.to_s)
41:       end
valid?(value, negated = false) click to toggle source
    # File lib/dm-types/json.rb, line 17
17:       def valid?(value, negated = false)
18:         super || dump(value).kind_of?(::String)
19:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.