Added scoped_resource constructor that takes an init function