Class: TaskHelper::Database

Inherits:
Base
  • Object
show all
Defined in:
lib/task_helper/database.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #created_at, #id, #initialize, #to_h, #updated_at

Constructor Details

This class inherits a constructor from TaskHelper::Base

Class Method Details

.allObject



5
6
7
# File 'lib/task_helper/database.rb', line 5

def self.all
  get(route: 'apps.json')['databases'].map { |d| new d }
end

.find(id) ⇒ Object



19
20
21
22
23
# File 'lib/task_helper/database.rb', line 19

def self.find(id)
  if response = get(route: "apps/#{id}.json")
    new response['database'] if response['database']
  end
end

.find_by(search) ⇒ Object



13
14
15
16
17
# File 'lib/task_helper/database.rb', line 13

def self.find_by(search)
  if response = get(route: 'apps/search.json', params: search)
    new response['database'] if response['database']
  end
end

.find_by_name(name) ⇒ Object



9
10
11
# File 'lib/task_helper/database.rb', line 9

def self.find_by_name(name)
  find_by(name: name)
end

Instance Method Details

#formsObject



25
26
27
28
# File 'lib/task_helper/database.rb', line 25

def forms
  @forms ||= Form.get(route: "apps/#{id}/entities.json")['forms']
    .map { |form| Form.new(form, database: self) }
end