From 1cbb5d01ef778a06721000ebaacc5bbdf445f486 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Fri, 11 Dec 2009 10:02:38 -0500 Subject: [PATCH] minor: added grid store length accessor --- lib/mongo/gridfs/grid_store.rb | 3 +++ test/test_grid_store.rb | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/mongo/gridfs/grid_store.rb b/lib/mongo/gridfs/grid_store.rb index 126026a..4011909 100644 --- a/lib/mongo/gridfs/grid_store.rb +++ b/lib/mongo/gridfs/grid_store.rb @@ -54,6 +54,9 @@ module GridFS # Default is DEFAULT_CONTENT_TYPE attr_accessor :content_type + # Size of file in bytes + attr_reader :length + attr_accessor :metadata attr_reader :files_id diff --git a/test/test_grid_store.rb b/test/test_grid_store.rb index d2c5a01..71a161b 100644 --- a/test/test_grid_store.rb +++ b/test/test_grid_store.rb @@ -71,6 +71,10 @@ class GridStoreTest < Test::Unit::TestCase assert_equal "hello", GridStore.read(@@db, 'foobar', 5) end + def test_access_length + assert_equal 13, GridStore.new(@@db, 'foobar').length + end + # Also tests seek def test_read_with_offset assert_equal "world", GridStore.read(@@db, 'foobar', 5, 7)