Sha256: 2f4691269d0ffa1f4d797c0c147d27a68a5dd872c7e80e3bfd0a56e6ca3f14c5

Contents?: true

Size: 467 Bytes

Versions: 52

Compression:

Stored size: 467 Bytes

Contents

module ActiveRecord
  class Fixture
    def find
      if model_class
        # CPK
        # model_class.find(fixture[model_class.primary_key])
        ids = self.ids(model_class.primary_key)
        model_class.find(ids)
      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

52 entries across 52 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.15 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.1 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.14 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.1.0 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.13 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-6.0.8 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-8.0.0 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.12 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.11 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-6.0.7 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.10 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.9 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.8 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.7 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.6 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.5 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.4 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.3 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.2 lib/composite_primary_keys/fixtures.rb
composite_primary_keys-7.0.1 lib/composite_primary_keys/fixtures.rb