Top Level Namespace
Defined Under Namespace
Modules: ActiveRecord, ChildInstanceMethods, Citier, ClassMethods, InstanceMethods, RootInstanceMethods
Constant Summary collapse
- CITIER_DEBUGGING =
(::Rails.env == 'development')
Instance Method Summary collapse
- #citier_debug(s) ⇒ Object
-
#create_citier_view(theclass) ⇒ Object
function for creating views for migrations.
-
#drop_citier_view(theclass) ⇒ Object
function for dropping views for migrations.
Instance Method Details
#citier_debug(s) ⇒ Object
3 4 5 6 7 |
# File 'lib/citier.rb', line 3 def citier_debug(s) if CITIER_DEBUGGING puts "citier -> " + s end end |
#create_citier_view(theclass) ⇒ Object
function for creating views for migrations
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/citier/core_ext.rb', line 32 def create_citier_view(theclass) #function for creating views for migrations self_columns = theclass::Writable.column_names.select{ |c| c != "id" } parent_columns = theclass.superclass.column_names.select{ |c| c != "id" } columns = parent_columns+self_columns self_read_table = theclass.table_name self_write_table = theclass::Writable.table_name parent_read_table = theclass.superclass.table_name sql = "CREATE VIEW #{self_read_table} AS SELECT #{parent_read_table}.id, #{columns.join(',')} FROM #{parent_read_table}, #{self_write_table} WHERE #{parent_read_table}.id = #{self_write_table}.id" citier_debug("Creating citier view -> #{sql}") theclass.connection.execute sql end |
#drop_citier_view(theclass) ⇒ Object
function for dropping views for migrations
44 45 46 47 48 49 |
# File 'lib/citier/core_ext.rb', line 44 def drop_citier_view(theclass) #function for dropping views for migrations self_read_table = theclass.table_name sql = "DROP VIEW #{self_read_table}" citier_debug("Dropping citier view -> #{sql}") theclass.connection.execute sql end |