Class: Kintone::Client::Middleware::Form

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/kintone/client/middleware/form.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = nil) ⇒ Form

Returns a new instance of Form.



3
4
5
# File 'lib/kintone/client/middleware/form.rb', line 3

def initialize(app, options = nil)
  super(app)
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kintone/client/middleware/form.rb', line 7

def call(env)
  @app.call(env).on_complete do |env|
    if record = env[:body]['record']
      env[:body]['record'] = parse_form(record)
    elsif records = env[:body]['records']
      env[:body]['records'] = records.map {|r| parse_form(r) }
    end

    if totalCount = env[:body]['totalCount']
      env[:body]['totalCount'] = totalCount.to_i
    end
  end
end