Sha256: 3dbd353d50a16f24f655675d0763f10bb987d9f3c59d26a10b5c05b7ffaba269

Contents?: true

Size: 591 Bytes

Versions: 19

Compression:

Stored size: 591 Bytes

Contents

module ActiveRecord
  class Fixture
    def find
      if model_class
        # CPK
        # model_class.unscoped do
        #   model_class.find(fixture[model_class.primary_key])
        # end
        model_class.unscoped do
          ids = self.ids(model_class.primary_key)
          model_class.find(ids)
        end
      else
        raise FixtureClassNotFound, "No class attached to find."
      end
    end

    def ids(key)
      if key.is_a? Array
        key.map {|a_key| fixture[a_key.to_s] }
      else
        fixture[key]
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
composite_primary_keys-11.3.1 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.8 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.7 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.2.0 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.1.0 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.3 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.2 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.1 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.0 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.0.rc1 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.0.beta4 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.0.beta3 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.0.beta2 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-11.0.0.beta1 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.6 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.5 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.4 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.3 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.2 lib/composite_primary_keys/fixtures.rb