Sha256: caadfeabb278e1fb006cf1fcd9391b6f58eb9e5c48cdb00229a285a864b99fe0

Contents?: true

Size: 458 Bytes

Versions: 14

Compression:

Stored size: 458 Bytes

Contents

module ActiveMocker
  module ActiveRecord
  # @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
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
active_mocker-1.8.4 lib/active_mocker/active_record/table.rb
active_mocker-1.8.3 lib/active_mocker/active_record/table.rb
active_mocker-1.8.2 lib/active_mocker/active_record/table.rb
active_mocker-1.8.1 lib/active_mocker/active_record/table.rb
active_mocker-1.8 lib/active_mocker/active_record/table.rb
active_mocker-1.7.3 lib/active_mocker/active_record/table.rb
active_mocker-1.7.2 lib/active_mocker/active_record/table.rb
active_mocker-1.7.1 lib/active_mocker/active_record/table.rb
active_mocker-1.7.1rc lib/active_mocker/active_record/table.rb
active_mocker-1.7 lib/active_mocker/active_record/table.rb
active_mocker-1.7rc2 lib/active_mocker/active_record/table.rb
active_mocker-1.7.beta3 lib/active_mocker/active_record/table.rb
active_mocker-1.7.beta2 lib/active_mocker/active_record/table.rb
active_mocker-1.7.beta1 lib/active_mocker/active_record/table.rb