lib/jsonapi/formatter.rb in jsonapi-resources-0.0.12 vs lib/jsonapi/formatter.rb in jsonapi-resources-0.0.13

- old
+ new

@@ -35,10 +35,22 @@ super.to_sym end end end + class RouteFormatter < Formatter + class << self + def format(route) + super + end + + def unformat(formatted_route) + super.to_sym + end + end + end + class ValueFormatter < Formatter class << self def format(raw_value, context) super(raw_value) end @@ -89,8 +101,35 @@ when String, Integer return raw_value else return raw_value.to_s end + end + end +end + +class UnderscoredRouteFormatter < JSONAPI::RouteFormatter +end + +class CamelizedRouteFormatter < JSONAPI::RouteFormatter + class << self + def format(route) + super.camelize(:lower) + end + + def unformat(formatted_route) + formatted_route.to_s.underscore.to_sym + end + end +end + +class DasherizedRouteFormatter < JSONAPI::RouteFormatter + class << self + def format(route) + super.dasherize + end + + def unformat(formatted_route) + formatted_route.to_s.underscore.to_sym end end end \ No newline at end of file