# File lib/rapid_runty/model/base.rb, line 26 def self.primary_key(primary) 'PRIMARY KEY AUTOINCREMENT' if primary end
class RapidRunty::Model::Base
Public Class Methods
column_names()
click to toggle source
# File lib/rapid_runty/model/base.rb, line 38 def self.column_names columns = [] @property.each do |column_name, constraints| properties_and_constraints = [] properties_and_constraints << column_name.to_s constraints.each do |attribute, value| properties_and_constraints << send(attribute.downcase.to_s, value) end columns << properties_and_constraints.join(' ') end columns end
create_table()
click to toggle source
# File lib/rapid_runty/model/base.rb, line 18 def self.create_table DB.execute_query( "CREATE TABLE IF NOT EXISTS #{@table}" \ "(#{column_names.join(', ')})" ) @property.keys.each(&method(:attr_accessor)) end
nullable(is_null)
click to toggle source
# File lib/rapid_runty/model/base.rb, line 30 def self.nullable(is_null) 'NOT NULL' unless is_null end
primary_key(primary)
click to toggle source
property(field, attr)
click to toggle source
# File lib/rapid_runty/model/base.rb, line 13 def self.property(field, attr) @property ||= {} @property[field] = attr end
to_table(name)
click to toggle source
# File lib/rapid_runty/model/base.rb, line 9 def self.to_table(name) @table = name.to_s end
type(value)
click to toggle source
# File lib/rapid_runty/model/base.rb, line 34 def self.type(value) value.to_s end