lib/yapper/extensions.rb in motion-yapper-0.0.1 vs lib/yapper/extensions.rb in motion-yapper-0.0.2
- old
+ new
@@ -39,42 +39,30 @@
dateFormatter.stringFromDate(self)
end
end
-class Object
- def as_json
- self
- end
-end
-
class Hash
- def as_json
- hash = self.class.new
- self.each { |k,v| hash[k] = v.as_json }
- hash
+ def to_canonical
+ self.keys.to_canonical + self.values.to_canonical
end
end
-class NSDictionary
- def as_json
- to_hash.as_json
- end
-end
-
class Array
- def as_json
- self.map { |v| v.as_json }
+ def to_canonical
+ self.map { |v| v.class.to_s == 'Class' ? v.to_s : v}.map(&:to_canonical).sort.join
end
end
-class NSArray
- def as_json
- self.map { |v| v.as_json }
+class String
+ def to_canonical
+ self
end
end
-class Time
- def as_json
- self.to_iso8601
+class Symbol
+ def to_canonical
+ to_s
end
end
+
+class Boolean; end