Class: Tarot::Database

Inherits:
Struct
  • Object
show all
Defined in:
lib/tarot.rb

Overview

Estrutura para representar uma database na API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



87
88
89
# File 'lib/tarot.rb', line 87

def id
  @id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



87
88
89
# File 'lib/tarot.rb', line 87

def name
  @name
end

Instance Method Details

#inspectObject



88
89
90
# File 'lib/tarot.rb', line 88

def inspect
  "<Metabase::Database id=#{id.inspect}, name=#{name.inspect}>"
end

#query(sql) ⇒ Object

Mesmo que Tarot.query(esse_banco, sql) Executa uma consulta SQL e retorna o resultado.

Parameters:

  • sql (String)

    Consulta SQL a ser executada.

Returns:

  • (Object)

    Resultado da API contendo a resposta da consulta ou um JSON com os erros que ocorreram.



109
110
111
# File 'lib/tarot.rb', line 109

def query(sql)
  Tarot.query(self, sql)
end

#query!(sql) ⇒ Object

Mesmo que Tarot.query!(esse_banco, sql) Executa uma consulta SQL e retorna o resultado. Levanta erro conforme resposta da API.

Parameters:

  • sql (String)

    Consulta SQL a ser executada.

Returns:

  • (Object)

    Resultado da consulta.

Raises:

  • (QueryError)

    Se ocorrer um erro na consulta.



101
102
103
# File 'lib/tarot.rb', line 101

def query!(sql)
  Tarot.query!(self, sql)
end

#to_sObject



92
93
94
# File 'lib/tarot.rb', line 92

def to_s
  "'#{name}'(id #{id})"
end