Class: Peictt::Migrations
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(type, *args) ⇒ Object
44
45
46
47
48
49
50
51
|
# 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
|
Instance Method Details
#create_table(table_name) {|_self| ... } ⇒ Object
3
4
5
6
7
|
# 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) ⇒ Object
9
10
11
12
13
|
# 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 ⇒ Object
15
16
17
18
|
# File 'lib/peictt/orm/migrations.rb', line 15
def timestamps
table_properties << "created_at DATETIME"
table_properties << "updated_at DATETIME"
end
|