class Cyby::Kintone::App
Constants
- LIMIT
Attributes
convert_to_camelized_field[RW]
Public Class Methods
new(id, convert_to_camelized_field = false)
click to toggle source
# File lib/cyby/kintone/app.rb, line 8 def initialize(id, convert_to_camelized_field = false) @api = RestApi.new(id) @convert_to_camelized_field = convert_to_camelized_field end
Public Instance Methods
all()
click to toggle source
# File lib/cyby/kintone/app.rb, line 68 def all relation.all end
asc(field)
click to toggle source
# File lib/cyby/kintone/app.rb, line 76 def asc(field) relation.asc(field) end
delete(record)
click to toggle source
# File lib/cyby/kintone/app.rb, line 54 def delete(record) json = { ids: [record["$id"]] } @api.delete("/records.json", json) true end
desc(field)
click to toggle source
# File lib/cyby/kintone/app.rb, line 80 def desc(field) relation.desc(field) end
find(params)
click to toggle source
# File lib/cyby/kintone/app.rb, line 13 def find(params) result = [] page = 0 begin records = find_per_page(params, page) result.concat(records) page += 1 end while records.count == LIMIT result end
find_per_page(params, page)
click to toggle source
# File lib/cyby/kintone/app.rb, line 24 def find_per_page(params, page) params_per_page = params.dup queries = [params[:query]] if page > 0 queries << "offset #{LIMIT * page}" end params_per_page[:query] = queries.join(" ") response = @api.get('/records.json', params_per_page) response['records'].map do |record| Record.new(self, record) end end
id()
click to toggle source
# File lib/cyby/kintone/app.rb, line 88 def id @api.app end
inspect()
click to toggle source
# File lib/cyby/kintone/app.rb, line 92 def inspect { id: id }.inspect end
new_record()
click to toggle source
# File lib/cyby/kintone/app.rb, line 60 def new_record Record.new(self) end
relation()
click to toggle source
# File lib/cyby/kintone/app.rb, line 64 def relation Relation.new(self) end
save(record)
click to toggle source
# File lib/cyby/kintone/app.rb, line 37 def save(record) if record.changed? json = record.to_json_for_save if json[:id] resp = @api.put("/record.json", json) else resp = @api.post("/record.json", json) record["$id"] = resp["id"] end record["$revision"] = resp["revision"] record.unchanged true else false end end
select(*fields)
click to toggle source
# File lib/cyby/kintone/app.rb, line 84 def select(*fields) relation.select(*fields) end
where(cond, *params)
click to toggle source
# File lib/cyby/kintone/app.rb, line 72 def where(cond, *params) relation.where(cond, *params) end