Sha256: 00b1c16c53955b55ec4142875e0eae5ca491dbabbe6a9c4c4d36c65152fb2507

Contents?: true

Size: 693 Bytes

Versions: 15

Compression:

Stored size: 693 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.first]
  end

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

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

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

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_mocker-1.1.11 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.10 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.9 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.8 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.7 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.6 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.5 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.4 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.3 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.2 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.1 lib/active_mocker/active_record/relationships.rb
active_mocker-1.1.0 lib/active_mocker/active_record/relationships.rb
active_mocker-1.0.1 lib/active_mocker/active_record/relationships.rb
active_mocker-1.0.0 lib/active_mocker/active_record/relationships.rb
active_mocker-0.4.0 lib/active_mocker/active_record/relationships.rb