Class: Arrest::Handlers::KeyConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/arrest/handler.rb

Overview

a converter to transform between the name of the field in the json object and the name of the field in ruby code. Special behaviour is that for an underscored name in ruby a camel cased version in json expected:

  ruby    ->     json
started_at    startedAt

Class Method Summary collapse

Class Method Details

.key_from_json(name) ⇒ Object



45
46
47
# File 'lib/arrest/handler.rb', line 45

def key_from_json name
  StringUtils.underscore(name.to_s)
end

.key_to_json(name) ⇒ Object



49
50
51
# File 'lib/arrest/handler.rb', line 49

def key_to_json name
  StringUtils.classify(name.to_s,false)
end