{"id":118,"date":"2009-08-23T14:10:10","date_gmt":"2009-08-23T19:10:10","guid":{"rendered":"http:\/\/somethingdoug.com\/thoughts\/?p=118"},"modified":"2009-08-23T14:12:35","modified_gmt":"2009-08-23T19:12:35","slug":"watching-upstream-dependencies","status":"publish","type":"post","link":"https:\/\/somethingdoug.com\/thoughts\/2009\/08\/23\/watching-upstream-dependencies\/","title":{"rendered":"Watching Upstream Dependencies"},"content":{"rendered":"<p>I am subscribed to the <a href=\"http:\/\/search.cpan.org\/uploads.rdf\">RSS feed for CPAN uploads<\/a> and watch for new versions of CPAN distributions my modules depend on and read their change logs. The other day I saw <a href=\"http:\/\/search.cpan.org\/~drolsky\/Moose-0.89\/\">Moose 0.89<\/a> come out and saw a new feature added where the trigger of an attribute will now receive the old value if there was one.<\/p>\n<pre lang=\"perl\">package Node;\r\n\r\nuse Moose 0.89;\r\n\r\nhas child => (\r\n  is  => 'rw',\r\n  isa => 'Node',\r\n  clearer   => 'clear_child',\r\n  predicate => 'has_child',\r\n  trigger   => \\&_child_trigger,\r\n);\r\nhas parent => (\r\n  is  => 'rw',\r\n  isa => 'Node',\r\n  clearer   => 'clear_parent',\r\n  predicate => 'has_parent',\r\n);\r\n\r\nbefore clear_child => sub {\r\n  my ($self) = @_;\r\n\r\n  # Trigger dissociate the parent from the child about to be cleared\r\n  $self->_child_trigger(undef, $self->child);\r\n\r\n  return;\r\n};\r\n\r\nsub _child_trigger {\r\n  my ($self, $child, $previous_child) = @_;\r\n\r\n  if (defined $previous_child) {\r\n    # Remove this node as the parent of the previous child\r\n    $previous_child->clear_parent();\r\n  }\r\n\r\n  if (defined $child) {\r\n    # Set this node as the parent of the new child\r\n    $child->parent($self);\r\n  }\r\n\r\n  return;\r\n}\r\n\r\nno Moose;\r\n\r\n1;<\/pre>\n<p>I quickly saw the benefit of this new feature for my <a href=\"http:\/\/search.cpan.org\/dist\/Authen-CAS-External\/\">Authen::CAS::External<\/a> distribution and incorporated this into the <code>cas_url<\/code> and the <code>user_agent<\/code> attributes. Now the associated LWP::UserAgent always has the proper handlers set up and strange issues where browsing to a CAS page with a user agent object formerly associated with Authen::CAS::External triggering the Authen::CAS::External library will no longer occur.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am subscribed to the RSS feed for CPAN uploads and watch for new versions of CPAN distributions my modules depend on and read their change logs. The other day I saw Moose 0.89 come out and saw a new feature added where the trigger of an attribute will now receive the old value if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[12,27,19],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-perl","tag-cpan","tag-perl","tag-perl5"],"_links":{"self":[{"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":7,"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":125,"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/posts\/118\/revisions\/125"}],"wp:attachment":[{"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/somethingdoug.com\/thoughts\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}