Module: CloudConnect::Fields

Included in:
Client
Defined in:
lib/cloud_connect/client/fields.rb

Instance Method Summary collapse

Instance Method Details

#fields(reload = false) ⇒ [Hashie::Mash]

Retrieve a list of fields. WARNING: This method uses calls not officially supported by Mobile Devices.

Returns:

  • ([Hashie::Mash])

    Array of Fields



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cloud_connect/client/fields.rb', line 8

def fields(reload = false)
  return @fields if @fields && !reload
  page  = 1
  limit = 100
  fields = []
  while (slice = connection.get(connection.build_url("fields", :per_page => limit, :page => page)).body).size > 0
    page += 1
    fields += slice.map!{|hash| hash.values.first} if slice.size > 0
    slice.size < limit ? break : sleep(1)
  end
  @fields = fields.sort_by(&:id)
end