summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-02-05 19:00:54 +0100
committerGitHub <noreply@github.com>2017-02-05 19:00:54 +0100
commit4d1282d1631e8ff50d9e4ab5bc01590649c712d7 (patch)
tree37d7dd43f63256c74759f1046817cb3e934d1671
parent3ffedec8b8d3c785166021543ff69c15c246632c (diff)
parentdea3a7b230adc2f7f39826428c4d5c15230ab8a8 (diff)
downloadimag-4d1282d1631e8ff50d9e4ab5bc01590649c712d7.zip
imag-4d1282d1631e8ff50d9e4ab5bc01590649c712d7.tar.gz
Merge pull request #893 from matthiasbeyer/libimagruby/impl-retrieve-for-mod
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