Module: DbAgile::Contract::Data::TableDriven

Included in:
Utils::Full
Defined in:
lib/dbagile/contract/data/table_driven.rb

Overview

Table driven methods of the contract

Instance Method Summary collapse

Instance Method Details

#dataset(table_or_query, proj = nil) ⇒ ...

Returns a dataset object for a given table (if a Symbol is given) or query (if a String is given).

As DbAgile aims at helping to manage SQL database access with respect to their schema, it does not specifies a detailed contract about the object returned here, which is related to queries, not schema modification. The kind of returned object is therefore left open to adapter specfic implementations.

We expect (mainly for tests) the following about datasets:

  • count: returns the number of records inside the dataset

  • to_a: returns an array of hashes representing records

Parameters:

  • table_or_query (Symbol | String)

    name of a table or query string

  • a (Hash | nil)

    tuple projection for query restriction

Returns:

  • (...)

    a dataset object with query (execution result)



28
29
30
# File 'lib/dbagile/contract/data/table_driven.rb', line 28

def dataset(table_or_query, proj = nil)
  Kernel.raise NotImplementedError
end

#exists?(table_or_query, subtuple = {}) ⇒ Boolean

Checks if a (sub)-tuple exists inside a table.

Parameters:

  • table_or_query (Symbol | String)

    name of a table or query string

  • subtuple (Hash) (defaults to: {})

    a tuple or tuple projection for the result

Returns:

  • (Boolean)

    true if the projection of the query result on subtuple’s heading contains the subtuple itself, false otherwise.



42
43
44
# File 'lib/dbagile/contract/data/table_driven.rb', line 42

def exists?(table_or_query, subtuple = {})
  Kernel.raise NotImplementedError
end