Module: Sqlyzer::Container

Included in:
Serializer
Defined in:
lib/sqlyzer/container.rb

Overview

This Mixin is dedicated to Sql components registering for one class extended by Sqlyzer::Serializer.

Here is the list of stored data :

  • name of the future Sql table (SQL_CONTAINER_TABLE),

  • primary keys of the future Sql table (SQL_CONTAINER_KEYS),

  • regular fields of the future Sql table (SQL_CONTAINER_VALUES).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sql_has_keys(owner, data) ⇒ Object

Register data into owner class as list of table primary keys. Call to this method will define or complete SQL_CONTAINER_KEYS constant.



118
119
120
# File 'lib/sqlyzer/container.rb', line 118

def     Container.sql_has_keys(owner, data)
  Container::sql_container_has owner, :SQL_CONTAINER_KEYS, data
end

.sql_has_values(owner, data) ⇒ Object

Register data into owner class as list of table regular fields. Call to this method will define or complete SQL_CONTAINER_VALUES constant.



126
127
128
# File 'lib/sqlyzer/container.rb', line 126

def     Container.sql_has_values(owner, data)
  Container::sql_container_has owner, :SQL_CONTAINER_VALUES, data
end

.sql_set_table(owner, name) ⇒ Object

Register name into owner class as the name of Sql table. Call to this method will define or redefine SQL_CONTAINER_TABLE constant.



134
135
136
# File 'lib/sqlyzer/container.rb', line 134

def     Container.sql_set_table(owner, name)
  Container::sql_container_set owner, :SQL_CONTAINER_TABLE, name.to_s.downcase
end

Instance Method Details

#sql_container_keysObject

Retreive the list of registered Sqlyzer::Parameter::Default class (stored in a Sqlyzer::Parameter::List object) as current class primary keys. This method is reading the constant named SQL_CONTAINER_KEYS.



50
51
52
# File 'lib/sqlyzer/container.rb', line 50

def     sql_container_keys
  self.class::SQL_CONTAINER_KEYS
end

#sql_container_tableObject

Retreive chosen table identifier for current class. This method is reading the constant named SQL_CONTAINER_TABLE.



41
42
43
# File 'lib/sqlyzer/container.rb', line 41

def     sql_container_table
  self.class::SQL_CONTAINER_TABLE
end

#sql_container_valuesObject

Retreive the list of registered Sqlyzer::Parameter::Default class (stored in a Sqlyzer::Parameter::List object) as current class regular table fields. This method is reading the constant named SQL_CONTAINER_VALUES.



59
60
61
# File 'lib/sqlyzer/container.rb', line 59

def     sql_container_values
  self.class::SQL_CONTAINER_VALUES
end