Class: ActiveMocker::Table
- Inherits:
-
Object
- Object
- ActiveMocker::Table
- Defined in:
- lib/active_mocker/table.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #column_names ⇒ Object
-
#initialize(name, fields = []) ⇒ Table
constructor
A new instance of Table.
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(name, fields = []) ⇒ Table
Returns a new instance of Table.
7 8 9 10 11 |
# File 'lib/active_mocker/table.rb', line 7 def initialize(name, fields=[]) @name = name @fields = fields fields.unshift Field.new('id', :integer, {}) end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/active_mocker/table.rb', line 5 def fields @fields end |
#name ⇒ Object (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_names ⇒ Object
19 20 21 |
# File 'lib/active_mocker/table.rb', line 19 def column_names fields.map { |f| f.name } end |
#to_h ⇒ Object Also known as: to_hash
13 14 15 |
# File 'lib/active_mocker/table.rb', line 13 def to_h {name: name, fields: fields.to_h} end |