cordawyn/redlander — pull request #8 by cordawyn (2014-08-08 09:12:52+00:00)
Title: "Lazy loading" of Statement, Node and Uri

Ruby objects for Statement, Node and Uri classes are instantiated "lazily" and there are no calls made to FFI (and, subsequently, to the underlying storage) unless it is absolutely necessary.
Previously, just a single `Statement.new(...)` statement introduced at least 1 to 4 calls, now it works as follows:
```
s = Statement.new(...) # creates a plain Ruby object without calls to FFI
s.subject # this where the necessary calls are made
```
Also notice that `subject`, `predicate`, `object` and several other accessors memoize their values to avoid the call to FFI (and the storage). For example, once `Statement.subject` is set, there won't be calls made to FFI to read it:
```
s = Statement.new(...)
s.subject = node # node is put into the storage
puts s.subject # storage is never accessed to get this value from now on
```

@abargnesi Do you think this makes sense? If it does, could you benchmark your project with it and see if it yields any boost? Thank you!