Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/tasks/db.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize ⇒ Table
constructor
A new instance of Table.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
Constructor Details
#initialize ⇒ Table
201 202 203 |
# File 'lib/tasks/db.rb', line 201 def initialize() @columns = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/tasks/db.rb', line 205 def method_missing(method_sym, *arguments, &block) c = Column.new c.type = method_sym.to_s c.name = arguments[0] c.opts = arguments[1] if c.opts c.default = c.opts["default"] c.default = c.opts["null"] aka = c.opts[:aka] if !aka.nil? if aka.respond_to?('each') c.akas = aka else c.akas = [aka] end end else c.opts = {} end @columns.append c end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
199 200 201 |
# File 'lib/tasks/db.rb', line 199 def columns @columns end |
#id ⇒ Object
Returns the value of attribute id.
199 200 201 |
# File 'lib/tasks/db.rb', line 199 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
199 200 201 |
# File 'lib/tasks/db.rb', line 199 def name @name end |
#opts ⇒ Object
Returns the value of attribute opts.
199 200 201 |
# File 'lib/tasks/db.rb', line 199 def opts @opts end |