lib/legion/json.rb in legion-json-1.1.7 vs lib/legion/json.rb in legion-json-1.2.0
- old
+ new
@@ -1,23 +1,26 @@
require 'legion/json/version'
require 'legion/json/parse_error'
+require 'legion/json/invalid_json'
+require 'json'
require 'multi_json'
module Legion
module JSON
- class << self
- def parser
- @parser ||= MultiJson
- end
+ def parser
+ @parser ||= MultiJson
+ end
+ module_function :parser
- def load(string, symbolize_keys = true)
- MultiJson.load(string, symbolize_keys: symbolize_keys)
- rescue StandardError => e
- raise Legion::JSON::ParseError.build(e, string)
- end
+ def load(string, symbolize_keys: true)
+ parser.load(string, symbolize_keys: symbolize_keys)
+ rescue StandardError => e
+ raise Legion::JSON::ParseError.build(e, string)
+ end
+ module_function :load
- def dump(object, pretty = false)
- parser.dump(object, pretty: pretty)
- end
+ def dump(object, pretty: false)
+ parser.dump(object, pretty: pretty)
end
+ module_function :dump
end
end