Skip to content

Commit

Permalink
Convert instance methods to class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alxberardi committed Dec 19, 2016
1 parent 90863d2 commit 108332a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/sensitive_data_filter/middleware/parameter_parser.rb
Expand Up @@ -40,18 +40,18 @@ def unparse(params)
->(params) { Rack::Utils.parse_query(params) },
->(params) { Rack::Utils.build_query(params) }),
new('json', # e.g.: 'application/json'
->(params) { JsonParser.new.parse(params) },
->(params) { JsonParser.new.unparse(params) })
->(params) { JsonParser.parse(params) },
->(params) { JsonParser.unparse(params) })
].freeze

class JsonParser
def parse(params)
def self.parse(params)
JSON.parse(params)
rescue JSON::ParserError
params
end

def unparse(params)
def self.unparse(params)
JSON.unparse(params)
rescue JSON::GeneratorError
params
Expand Down

0 comments on commit 108332a

Please sign in to comment.