Class: Table

Inherits:
Object
  • Object
show all
Defined in:
lib/infold/table.rb

Defined Under Namespace

Classes: Column

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Table

Returns a new instance of Table.



8
9
10
11
# File 'lib/infold/table.rb', line 8

def initialize(name)
  self.name = name
  self.columns = []
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



3
4
5
# File 'lib/infold/table.rb', line 3

def columns
  @columns
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/infold/table.rb', line 3

def name
  @name
end

Instance Method Details

#add_columns(name, type) ⇒ Object



17
18
19
# File 'lib/infold/table.rb', line 17

def add_columns(name, type)
  self.columns << Column.new(name, type)
end

#datetime_columnsObject



21
22
23
24
# File 'lib/infold/table.rb', line 21

def datetime_columns
  _columns = columns.select{ |c| c.type == 'datetime' && !%w(created_at updated_at).include?(c.name) }
  _columns.map(&:name)
end

#model_nameObject



13
14
15
# File 'lib/infold/table.rb', line 13

def model_name
  name.singularize.camelize
end