Class: JsonApiClient::Formatter

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

Direct Known Subclasses

KeyFormatter, RouteFormatter, ValueFormatter

Class Method Summary collapse

Class Method Details

.format(arg) ⇒ Object


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

def format(arg)
  arg.to_s
end

.formatter_for(format) ⇒ Object


18
19
20
21
# File 'lib/json_api_client/formatter.rb', line 18

def formatter_for(format)
  formatter_class_name = "JsonApiClient::#{format.to_s.camelize}Formatter"
  formatter_class_name.safe_constantize
end

.unformat(arg) ⇒ Object


12
13
14
15
16
# File 'lib/json_api_client/formatter.rb', line 12

def unformat(arg)
   # We call to_s() here so that unformat consistently returns a string
   # (instead of a symbol) regardless which Formatter subclass it is called on
  arg.to_s
end