Class: Table

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTable



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

#columnsObject

Returns the value of attribute columns.



199
200
201
# File 'lib/tasks/db.rb', line 199

def columns
  @columns
end

#idObject

Returns the value of attribute id.



199
200
201
# File 'lib/tasks/db.rb', line 199

def id
  @id
end

#nameObject

Returns the value of attribute name.



199
200
201
# File 'lib/tasks/db.rb', line 199

def name
  @name
end

#optsObject

Returns the value of attribute opts.



199
200
201
# File 'lib/tasks/db.rb', line 199

def opts
  @opts
end