Sha256: 1630b3530cbad023fb823e9a65f86aa0621b8df0f116087a412f295ae6a7d095

Contents?: true

Size: 646 Bytes

Versions: 15

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true
module ActiveMocker
  class MockCreator
    module Associations
      def has_many
        relation_find(:type, __method__)
      end

      def has_one
        relation_find(:type, __method__)
      end

      def belongs_to
        relation_find(:type, __method__)
      end

      def has_and_belongs_to_many
        relation_find(:type, __method__)
      end

      def relation_find(key, value)
        association_collection.select { |r| r.send(key).to_sym == value }
      end

      def association_collection
        @association_collection ||= schema_scrapper.associations.to_a
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_mocker-2.6.2 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.6.1.beta2 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.6.1.beta lib/active_mocker/mock_creator/associations.rb
active_mocker-2.6.0 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.5.4 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.5.3 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.5.2 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.5.1 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.5.1.pre lib/active_mocker/mock_creator/associations.rb
active_mocker-2.5.0 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.4.4 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.4.3 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.4.2 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.4.1 lib/active_mocker/mock_creator/associations.rb
active_mocker-2.4.0 lib/active_mocker/mock_creator/associations.rb