Module: Bj::Table::ClassMethods
- Defined in:
- lib/bj/table.rb
Instance Method Summary (collapse)
- - (Object) content_column_names
- - (Object) create_hash_for(options)
- - (Object) down
- - (Object) each(*a, &b)
- - (Object) migration_class
- - (Object) migration_code(classname = "BjMigration" )
- - (Object) reverse_each(*a, &b)
- - (Object) up
Instance Method Details
- (Object) content_column_names
44 45 46 |
# File 'lib/bj/table.rb', line 44 def content_column_names @content_column_names = content_columns.map{|column| column.name} end |
- (Object) create_hash_for(options)
48 49 50 51 52 53 54 55 56 |
# File 'lib/bj/table.rb', line 48 def create_hash_for . hash = {} content_column_names.each do |key| key = key.to_s.to_sym hash[key] = [key] end hash end |
- (Object) down
27 28 29 |
# File 'lib/bj/table.rb', line 27 def down migration_class.down end |
- (Object) each(*a, &b)
58 59 60 |
# File 'lib/bj/table.rb', line 58 def each *a, &b list.each *a, &b end |
- (Object) migration_class
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bj/table.rb', line 31 def migration_class table = self @migration_class ||= Class.new(ActiveRecord::Migration) do sc = class << self self end sc.module_eval{ fattr :table => table } sc.module_eval &table.migration end end |
- (Object) migration_code(classname = "BjMigration" )
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bj/table.rb', line 10 def migration_code classname = "BjMigration" <<-code class #{ classname } < ActiveRecord::Migration def self.up Bj::Table.each{|table| table.up} end def self.down Bj::Table.reverse_each{|table| table.down} end end code end |
- (Object) reverse_each(*a, &b)
62 63 64 |
# File 'lib/bj/table.rb', line 62 def reverse_each *a, &b list.reverse.each *a, &b end |
- (Object) up
23 24 25 |
# File 'lib/bj/table.rb', line 23 def up migration_class.up end |