lib/jsonapi/formatter.rb in jsonapi-resources-0.2.0 vs lib/jsonapi/formatter.rb in jsonapi-resources-0.3.0.pre1

- old
+ new

@@ -7,34 +7,25 @@ def unformat(arg) arg end - # :nocov: - if RUBY_VERSION >= '2.0' - def formatter_for(format) - formatter_class_name = "#{format.to_s.camelize}Formatter" - Object.const_get formatter_class_name if formatter_class_name - end - else - def formatter_for(format) - formatter_class_name = "#{format.to_s.camelize}Formatter" - formatter_class_name.safe_constantize if formatter_class_name - end + def formatter_for(format) + formatter_class_name = "#{format.to_s.camelize}Formatter" + formatter_class_name.safe_constantize if formatter_class_name end - # :nocov: end end class KeyFormatter < Formatter class << self def format(key) super end def unformat(formatted_key) - super.to_sym + super end end end class RouteFormatter < Formatter @@ -42,11 +33,11 @@ def format(route) super end def unformat(formatted_route) - super.to_sym + super end end end class ValueFormatter < Formatter @@ -75,11 +66,11 @@ def format(key) super.camelize(:lower) end def unformat(formatted_key) - formatted_key.to_s.underscore.to_sym + formatted_key.to_s.underscore end end end class DasherizedKeyFormatter < JSONAPI::KeyFormatter @@ -87,11 +78,11 @@ def format(key) super.dasherize end def unformat(formatted_key) - formatted_key.to_s.underscore.to_sym + formatted_key.to_s.underscore end end end class DefaultValueFormatter < JSONAPI::ValueFormatter @@ -119,11 +110,11 @@ def format(route) super.camelize(:lower) end def unformat(formatted_route) - formatted_route.to_s.underscore.to_sym + formatted_route.to_s.underscore end end end class DasherizedRouteFormatter < JSONAPI::RouteFormatter @@ -131,9 +122,9 @@ def format(route) super.dasherize end def unformat(formatted_route) - formatted_route.to_s.underscore.to_sym + formatted_route.to_s.underscore end end end