Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/swiss_db/db.rb
Overview
schema loader stuff i know it’s rough but it works
Instance Attribute Summary collapse
-
#current_schema ⇒ Object
Returns the value of attribute current_schema.
Instance Method Summary collapse
- #add_column(name, type) ⇒ Object
- #entity(class_name, &block) ⇒ Object
- #integer32(column_name) ⇒ Object
-
#log(tag, str) ⇒ Object
convenience methods.
- #puts(str) ⇒ Object
- #schema(schema_name, &block) ⇒ Object
- #string(column_name) ⇒ Object
Instance Attribute Details
#current_schema ⇒ Object
Returns the value of attribute current_schema.
9 10 11 |
# File 'lib/swiss_db/db.rb', line 9 def current_schema @current_schema end |
Instance Method Details
#add_column(name, type) ⇒ Object
43 44 45 |
# File 'lib/swiss_db/db.rb', line 43 def add_column(name, type) @current_schema[@table_name][name] = type end |
#entity(class_name, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/swiss_db/db.rb', line 33 def entity(class_name, &block) table_name = class_name.tableize puts "adding entity #{table_name} to schema" @table_name = table_name @current_schema[@table_name] = {} block.call $current_schema = @current_schema DataStore.current_schema = @current_schema end |
#integer32(column_name) ⇒ Object
57 58 59 |
# File 'lib/swiss_db/db.rb', line 57 def integer32(column_name) add_column column_name.to_s, "INTEGER" end |
#log(tag, str) ⇒ Object
convenience methods
13 14 15 |
# File 'lib/swiss_db/db.rb', line 13 def log(tag, str) Android::Util::Log.d(tag, str) end |
#puts(str) ⇒ Object
17 18 19 |
# File 'lib/swiss_db/db.rb', line 17 def puts(str) log "general", str end |
#schema(schema_name, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/swiss_db/db.rb', line 25 def schema(schema_name, &block) puts "running schema for #{schema_name}" @current_schema = {} @database_name = schema_name block.call puts @current_schema.inspect end |
#string(column_name) ⇒ Object
53 54 55 |
# File 'lib/swiss_db/db.rb', line 53 def string(column_name) add_column column_name.to_s, "VARCHAR" end |