Sha256: a4ed81aa3ab72d92299e725684a62f28fd06dcb2359e4b50986a5a3ab340d0ed

Contents?: true

Size: 661 Bytes

Versions: 2

Compression:

Stored size: 661 Bytes

Contents

require 'ostruct'

module Relationships

  def relationships
    OpenStruct.new({has_many:   @has_many   ||= [],
                    has_one:    @has_one    ||= [],
                    belongs_to: @belongs_to ||= [],
                    has_and_belongs_to_many: @has_and_belongs_to_many ||= []})
  end

  private

  def has_many(*args)
    @has_many ||= []
    @has_many.push args
  end

  def has_one(*args)
    @has_one ||= []
    @has_one.push args
  end

  def belongs_to(*args)
    @belongs_to ||= []
    @belongs_to.push args
  end

  def has_and_belongs_to_many(*args)
    @has_and_belongs_to_many ||= []
    @has_and_belongs_to_many.push args
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_mocker-0.3.1 lib/active_mocker/active_record/relationships.rb
active_mocker-0.1.1 lib/active_mocker/active_record/relationships.rb