Class: JSONAPI::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/formatter.rb

Direct Known Subclasses

KeyFormatter, RouteFormatter, ValueFormatter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.format(arg) ⇒ Object



4
5
6
# File 'lib/jsonapi/formatter.rb', line 4

def format(arg)
  arg.to_s
end

.unformat(arg) ⇒ Object



8
9
10
# File 'lib/jsonapi/formatter.rb', line 8

def unformat(arg)
  arg
end

Instance Method Details

#formatter_for(format) ⇒ Object



14
15
16
17
# File 'lib/jsonapi/formatter.rb', line 14

def formatter_for(format)
  formatter_class_name = "#{format.to_s.camelize}Formatter"
  Object.const_get formatter_class_name if formatter_class_name
end