Class: ActiveMocker::Table

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, fields = []) ⇒ Table

Returns a new instance of Table.



7
8
9
10
# File 'lib/active_mocker/table.rb', line 7

def initialize(name, fields=[])
  @name   = name
  @fields = fields
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



5
6
7
# File 'lib/active_mocker/table.rb', line 5

def fields
  @fields
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/active_mocker/table.rb', line 5

def name
  @name
end

Instance Method Details

#column_namesObject



16
17
18
# File 'lib/active_mocker/table.rb', line 16

def column_names
  fields.map { |f| f.name }
end

#to_hObject



12
13
14
# File 'lib/active_mocker/table.rb', line 12

def to_h
  {name: name, fields: fields.to_h}
end