> >>         def actual_content
> >>             if defined?(@actual_content) and @actual_content
> >>                 return @actual_content
> >>             end
> >>
> >> -            if s = resource.parameter(:source)
> >> -                return s.content
> >> -            end
> >> -            fail "Could not find actual content from checksum"
> >> +            return nil
> >> +        end
> >> +
> >>
> >
> > :-)  So that would be:
> >
> >         def actual_content
> >             @actual_content
> >         end
>
> I left it like it was so that your code smell automated refactoring
> would find it :-D
>
> *laugh*  That was very thoughtful of you.

>> +
> >> +        def local?
> >> +            if found? and uri
> >> +                return uri.scheme == "file" || uri.scheme == nil
> >> +            end
> >> +            false
> >> +        end
> >>
> >
> > How about this (reading "||" as "defaults to"):
> >
> >         def local?
> >             found? and uri and (uri.scheme || "file") == "file"
> >         end
>
> I'm always amazed by this kind of construction :-)
> Note that I don't find it readable...
>

It seems _more_ readable to me, which I expect is a matter of perspective.
Let me try to export the perspective, and see if that helps or makes things
worse,   I read:

         def local?
             found? and uri and (uri.scheme || "file") == "file"
         end

As

     local means it's found, has a uri, and the uri's scheme (which defaults
to "file") is file

...which maps pretty much straight across to the code (everything in order,
all the bits of code have natural language counterparts and visa versa).  In
contrast,

        def local?
            if found? and uri
                return uri.scheme == "file" || uri.scheme == nil
            end
            false
        end

...tells me more about how to compute local, but not so much what it means.

Happy AFK weekend...

-- Markus

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to