class Peictt::Migrations
Public Instance Methods
create_table(table_name) { |self| ... }
click to toggle source
# File lib/peictt/orm/migrations.rb, line 3 def create_table(table_name) @table_name = table_name.to_s.pluralize yield self migrate end
drop(table_name)
click to toggle source
# File lib/peictt/orm/migrations.rb, line 9 def drop(table_name) @table_name = table_name Database.execute_query drop_table_query true end
timestamps()
click to toggle source
# File lib/peictt/orm/migrations.rb, line 15 def timestamps table_properties << "created_at DATETIME" table_properties << "updated_at DATETIME" end
Private Instance Methods
create_table_query()
click to toggle source
# File lib/peictt/orm/migrations.rb, line 35 def create_table_query "CREATE TABLE IF NOT EXISTS #{@table_name}"\ "(#{@table_properties.join ', '})" end
drop_table_query()
click to toggle source
# File lib/peictt/orm/migrations.rb, line 40 def drop_table_query "DROP TABLE IF EXISTS #{@table_name}" end
method_missing(type, *args)
click to toggle source
# File lib/peictt/orm/migrations.rb, line 44 def method_missing(type, *args) @column_name = args[0] @column_type = type.to_s.upcase @options = args[1] if args[1].is_a? Hash table_properties << "#{@column_name} #{@column_type} "\ "#{parse_options(@options.dup).join(' ')}" @options = {} end
migrate()
click to toggle source
# File lib/peictt/orm/migrations.rb, line 26 def migrate Database.execute_query create_table_query true end
parse_options(options = {})
click to toggle source
# File lib/peictt/orm/migrations.rb, line 31 def parse_options(options = {}) Peictt::ConstraintsParser.parse options end
respond_to_missing?(type, include_private = false)
click to toggle source
Calls superclass method
# File lib/peictt/orm/migrations.rb, line 53 def respond_to_missing?(type, include_private = false) super end
table_properties()
click to toggle source
# File lib/peictt/orm/migrations.rb, line 22 def table_properties @table_properties ||= [] end