Loading ...
Sorry, an error occurred while loading the content.

can(method)

Expand Messages
  • Klaus Guenter
    Hi, list! I dont think, I m the first to stumble over that, but where the heck do I find the can() method. Lots of methods are generated on the fly, AFAICS
    Message 1 of 5 , May 11 7:07 AM
    • 0 Attachment
      Hi, list!

      I dont think, I'm the first to stumble over that, but where the heck
      do I find the can() method. Lots of methods are generated on the fly, AFAICS
      but no "can"

      Background:

      I would like to implement access control based on hosts/uid/.... and I dont
      want to reinvent the wheel. I got the hint at perl monks to look for "->can"
      and found a lot of "if $o->can(method) then do something" but no
      definition/generation of this method.

      Any hint is appreciated.

      Confused,
      Klaus
      --
      People often find it easier to be a result of the past than a cause of
      the future.
      -
    • Paul Kulchenko
      Klaus, I may have misunderstood the question, but can() method has nothing to do with SOAP::Lite. can() method (can be called as $obj- can( method ) or
      Message 2 of 5 , May 11 9:09 AM
      • 0 Attachment
        Klaus,

        I may have misunderstood the question, but can() method has nothing
        to do with SOAP::Lite. can() method (can be called as
        $obj->can('method') or UNIVERSAL::can($obj => 'method')) only tells
        you whether the object has a method 'method' (it actually returns
        undef or a reference to the sub). It won't work with methods that are
        dynamically generated unless that method was called on any object of
        that type already.

        To answer your access control question. I'm not sure what the context
        of the suggestion you got from perl monks was, but I don't see how
        ->can() can help you with that. You can read more about can() method
        in perlobj (try "perldoc perlobj"). Hope this helps.

        Best wishes, Paul.

        --- Klaus Guenter <klaus.guenter@...> wrote:
        > Hi, list!
        >
        > I dont think, I'm the first to stumble over that, but where the
        > heck
        > do I find the can() method. Lots of methods are generated on the
        > fly, AFAICS
        > but no "can"
        >
        > Background:
        >
        > I would like to implement access control based on hosts/uid/....
        > and I dont
        > want to reinvent the wheel. I got the hint at perl monks to look
        > for "->can"
        > and found a lot of "if $o->can(method) then do something" but no
        > definition/generation of this method.
        >
        > Any hint is appreciated.
        >
        > Confused,
        > Klaus
        > --
        > People often find it easier to be a result of the past than a cause
        > of
        > the future.
        > -
        >
        >
        > ------------------------ Yahoo! Groups Sponsor
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
      • eric-amick@comcast.net
        ... can() is defined in the class UNIVERSAL, which all classes inherit from automatically. See perldoc perltoot. -- Eric Amick Columbia, MD
        Message 3 of 5 , May 11 9:19 AM
        • 0 Attachment
          > I dont think, I'm the first to stumble over that, but where the heck
          > do I find the can() method. Lots of methods are generated on the fly, AFAICS
          > but no "can"

          can() is defined in the class UNIVERSAL, which all classes inherit from automatically. See perldoc perltoot.

          --
          Eric Amick
          Columbia, MD
        • Juan Jose Natera Abreu
          Hi, how about this? man UNIVERSAL man perlobj can is a special method all objects in perl have, it s used to tell if that object has ( can call) a
          Message 4 of 5 , May 11 9:35 AM
          • 0 Attachment
            Hi, how about this?

            man UNIVERSAL
            man perlobj

            'can' is a special method all objects in perl have, it's used to tell if that
            object has ('can' call) a particular method, I guess you can override it by
            simply defining your own:

            sub can {
            $self = shift;
            ...
            }

            You probably don't want to do this, simply rename your acl check to something
            like 'can_do' or 'has_access_to' or whatever.

            JJ

            PS. maybe I misunderstood what you were talking about it.

            On Tuesday 11 May 2004 07:07, Klaus Guenter wrote:
            > Hi, list!
            >
            > I dont think, I'm the first to stumble over that, but where the heck
            > do I find the can() method. Lots of methods are generated on the fly,
            > AFAICS but no "can"
            >
            > Background:
            >
            > I would like to implement access control based on hosts/uid/.... and I dont
            > want to reinvent the wheel. I got the hint at perl monks to look for
            > "->can" and found a lot of "if $o->can(method) then do something" but no
            > definition/generation of this method.
            >
            > Any hint is appreciated.
            >
            > Confused,
            > Klaus
          • Klaus Guenter
            Hi, Paul && list, Thx for all you answers ... On Tuesday 11 May 2004 18:09, Paul Kulchenko wrote: --snip-- ... --/snip-- I misunderstood that as a kind of
            Message 5 of 5 , May 12 12:09 AM
            • 0 Attachment
              Hi, Paul && list,

              Thx for all you answers ...

              On Tuesday 11 May 2004 18:09, Paul Kulchenko wrote:

              --snip--
              > UNIVERSAL::can($obj => 'method')) only tells
              > you whether the object has a method 'method' (it actually returns
              > undef or a reference to the sub).
              --/snip--

              I misunderstood that as a kind of access control. 'perltoot' would have been
              my friend .. but still isn't that suitable to implement access control?

              As Juan suggested, 'can' could be overriden and grant access (return ref ||
              undef) based on some criteria. Unless I misinterpreted that, 'can' is always
              used before the real work is done in SOAP::Lite.

              So, the call would fail, if 'can' decides: "You cant!" and return undef.

              How far am I off track? ;o)

              Best regards,
              Klaus
              --
              People often find it easier to be a result of the past than a cause of
              the future.
              -
            Your message has been successfully submitted and would be delivered to recipients shortly.