Class: ActiveMocker::Table Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Table.

API:

  • private



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

def initialize(name, id=true, fields=[])
  @name   = name
  @fields = fields
  fields.unshift Field.new('id', :integer, [{primary_key: true}]) if id.nil?
end

Instance Attribute Details

#fieldsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



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

def fields
  @fields
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



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

def name
  @name
end

Instance Method Details

#column_namesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



19
20
21
# File 'lib/active_mocker/table.rb', line 19

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

#to_hObject Also known as: to_hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



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

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