Sha256: f1ff7650f7f20f5c0c3993ba8a8446830e63090d823c3d2e7a68b0b33823927e

Contents?: true

Size: 431 Bytes

Versions: 5

Compression:

Stored size: 431 Bytes

Contents

module ActiveMocker
  # @api private
  class Table

    attr_reader :name, :fields

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

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

    alias_method :to_hash, :to_h

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

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active_mocker-1.6.4 lib/active_mocker/table.rb
active_mocker-1.6.3 lib/active_mocker/table.rb
active_mocker-1.6.2 lib/active_mocker/table.rb
active_mocker-1.6.1 lib/active_mocker/table.rb
active_mocker-1.6 lib/active_mocker/table.rb