Methods
- B
- R
- S
Instance Public methods
backing_store_create(model)
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 49 def backing_store_create(model) 50 attr_map = sheet.list.keys.index_by(&:downcase) 51 52 # ID won't be mapped 53 attrs = model.serializable_hash(except: :id).transform_keys { |k| attr_map[k] } 54 55 sheet.list.push(attrs) 56 57 sheet.synchronize 58 end
backing_store_destroy()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 21 def backing_store_destroy 22 sheet.delete_rows(id + 1, 1) 23 24 sheet.synchronize 25 end
backing_store_index()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 39 def backing_store_index 40 sheet.reload 41 42 idx = 0 43 sheet.list.map do |row| 44 idx += 1 45 row_to_instance(row, idx) 46 end 47 end
backing_store_show(id)
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 60 def backing_store_show(id) 61 sheet.reload 62 63 row_to_instance(sheet.list[id.to_i - 1], id) 64 end
backing_store_update()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 10 def backing_store_update 11 attr_map = sheet.list.keys.index_by(&:downcase) 12 13 # ID won't be mapped 14 attrs = serializable_hash(except: :id).transform_keys { |k| attr_map[k] } 15 16 sheet.list[id - 1].update(attrs) 17 18 sheet.synchronize 19 end
row_to_instance(row, id)
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 79 def row_to_instance(row, id) 80 attrs = row.to_hash 81 attrs = attrs.transform_keys(&:downcase).transform_keys(&:to_sym) 82 new(attrs.merge(id: id)) 83 end
sheet()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb 66 def sheet 67 return @google_worksheet if @google_worksheet 68 69 @google_client = GoogleDrive::Session.from_service_account_key(nil) 70 71 # Pass the sheet id 72 @google_sheet = @google_client.spreadsheet_by_key(sheet_id) 73 74 return @google_worksheet = @google_sheet.worksheet_by_title(work_sheet_title) if work_sheet_title 75 76 @google_worksheet = @google_sheet.worksheets[0] 77 end