Module: Tripletexer::FormatHelpers

Included in:
Endpoints::AbstractEndpoint
Defined in:
lib/tripletexer/format_helpers.rb

Instance Method Summary collapse

Instance Method Details

#format_date(value) ⇒ Object



2
3
4
5
# File 'lib/tripletexer/format_helpers.rb', line 2

def format_date(value)
  return value if value.is_a? String
  value.to_date.to_s
end

#normalize_body(body) ⇒ Object

Raises:

  • (ArtumentError)


7
8
9
10
11
# File 'lib/tripletexer/format_helpers.rb', line 7

def normalize_body(body)
  return body if body.is_a?(String)
  return JSON.dump(body) if body.is_a?(Hash) || body.is_a?(Array)
  raise ArtumentError, 'unsupported body type'
end