{"action":"created","issue":{"url":"https://api.github.com/repos/oliwer/mango/issues/2","labels_url":"https://api.github.com/repos/oliwer/mango/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/oliwer/mango/issues/2/comments","events_url":"https://api.github.com/repos/oliwer/mango/issues/2/events","html_url":"https://github.com/oliwer/mango/issues/2","id":55418434,"number":2,"title":"$self->mango undefined inside Mango::Database","user":{"login":"jkramer","id":6999,"avatar_url":"https://avatars.githubusercontent.com/u/6999?v=3","gravatar_id":"","url":"https://api.github.com/users/jkramer","html_url":"https://github.com/jkramer","followers_url":"https://api.github.com/users/jkramer/followers","following_url":"https://api.github.com/users/jkramer/following{/other_user}","gists_url":"https://api.github.com/users/jkramer/gists{/gist_id}","starred_url":"https://api.github.com/users/jkramer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkramer/subscriptions","organizations_url":"https://api.github.com/users/jkramer/orgs","repos_url":"https://api.github.com/users/jkramer/repos","events_url":"https://api.github.com/users/jkramer/events{/privacy}","received_events_url":"https://api.github.com/users/jkramer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-25T15:06:14Z","updated_at":"2015-02-03T19:39:03Z","closed_at":"2015-02-03T19:39:02Z","body":"This code:\r\n\r\n    my $m = Mango->new->db('abc')->collection('xyz');\r\n    $m->insert(...)\r\n\r\nGives me this error:\r\n\r\n    Can't call method \"j\" on an undefined value at .../perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/Mango/Database.pm line 14.\r\n\r\nHowever this:\r\n\r\n    my $mango = Mango->new;\r\n    my $m = $mango->db('abc')->collection('xyz');\r\n    $m->insert(...)\r\n\r\nworks just fine."},"comment":{"url":"https://api.github.com/repos/oliwer/mango/issues/comments/72719013","html_url":"https://github.com/oliwer/mango/issues/2#issuecomment-72719013","issue_url":"https://api.github.com/repos/oliwer/mango/issues/2","id":72719013,"user":{"login":"oliwer","id":644874,"avatar_url":"https://avatars.githubusercontent.com/u/644874?v=3","gravatar_id":"","url":"https://api.github.com/users/oliwer","html_url":"https://github.com/oliwer","followers_url":"https://api.github.com/users/oliwer/followers","following_url":"https://api.github.com/users/oliwer/following{/other_user}","gists_url":"https://api.github.com/users/oliwer/gists{/gist_id}","starred_url":"https://api.github.com/users/oliwer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliwer/subscriptions","organizations_url":"https://api.github.com/users/oliwer/orgs","repos_url":"https://api.github.com/users/oliwer/repos","events_url":"https://api.github.com/users/oliwer/events{/privacy}","received_events_url":"https://api.github.com/users/oliwer/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T19:39:02Z","updated_at":"2015-02-03T19:39:02Z","body":"It is just like @dotandimet said. That is why you are advised to create a helper subroutine like this:\r\n\r\n    sub mango { state $m = Mango->new(\"mongodb://...\") }\r\n\r\nand always access to your database through this helper.\r\n\r\nNote that this behavior will probably change in the future when support for replica set monitoring has been implemented."}}