summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-02-05 16:03:18 +0100
committerMatthias Beyer <mail@beyermatthias.de>2017-02-05 18:35:39 +0100
commitdea3a7b230adc2f7f39826428c4d5c15230ab8a8 (patch)
tree29167e29b6dc0c730f2372ef46f51913408c0100
parent63ffbf62de95dfed62d3c41588472c3c8056a5a6 (diff)
downloadimag-dea3a7b230adc2f7f39826428c4d5c15230ab8a8.zip
imag-dea3a7b230adc2f7f39826428c4d5c15230ab8a8.tar.gz
Impl Store::retrieve_for_module() interface function
-rw-r--r--libimagruby/src/store.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/libimagruby/src/store.rs b/libimagruby/src/store.rs
index dbf1555..f20481b 100644
--- a/libimagruby/src/store.rs
+++ b/libimagruby/src/store.rs
@@ -386,7 +386,30 @@ methods!(
// On error: Nil + Exception
//
fn retrieve_for_module(name: RString) -> AnyObject {
- unimplemented!()
+ use entry::FileLockEntryHandle as FLEH;
+ use ruru::Array;
+
+ let name = typecheck!(name or return any NilClass::new()).to_string();
+
+ call_on_store! {
+ store <- itself wrapped inside STORE_WRAPPER,
+ operation {
+ match store.retrieve_for_module(&name) {
+ Err(e) => {
+ trace_error(&e);
+ VM::raise(Class::from_existing("RuntimeError"), e.description());
+ NilClass::new().to_any_object()
+ },
+ Ok(iter) => {
+ let store_handle = itself.get_data(&*STORE_WRAPPER).clone();
+ iter.map(|sid| FLEH::new(store_handle.clone(), sid).wrap())
+ .fold(Array::new(), |mut a, e| a.push(e))
+ .to_any_object()
+ },
+ }
+ },
+ on fail return NilClass::new().to_any_object()
+ }
}
// Update a FileLockEntry in the store