---
name: "UR::Object::Command::FetchAndDo"
section: "3pm"
platform: "linux"
package: "libur-perl"
version: "0.470+ds-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/UR::Object::Command::FetchAndDo"
---

# UR::Object::Command::FetchAndDo(3pm)

Base class for fetching objects and then performing a function on/with them.

## NAME

UR::Object::Command::FetchAndDo - Base class for fetching objects and then performing a function on/with them.

## SYNOPSIS

```
 package MyFecthAndDo;
 use strict;
 use warnings;
 use above "UR";
 class MyFecthAndDo {
     is => 'UR::Object::Command::FetchAndDo',
     has => [
     # other properties...
     ],
 };
 sub _do { # required
    my ($self, $iterator) = @_;
    while (my $obj = $iterator->next) {
        ...
    }
    return 1;
 }

 1;
```

## Provided by the Developer

### \_do (required)

Implement this method to 'do' unto the iterator.  Return true for success, false for failure.

```
 sub _do {
    my ($self, $iterator) = @_;
    while (my $obj = $iterator->next) {
        ...
    }
    return 1;
 }
```

### subject\_class\_name (optional)

The subject\_class\_name is the class for which the objects will be fetched.  It can be specified one of two main ways:

- *by\_the\_end\_user\_on\_the\_command\_line*

  For this do nothing, the end user will have to provide it when the command is run.

- *by\_the\_developer\_in the\_class\_declartion*

  For this, in the class declaration, add a has key w/ arrayref of hashrefs.  One of the hashrefs needs to be subject\_class\_name.  Give it this declaration:

  ```
   class MyFetchAndDo {
       is => 'UR::Object::Command::FetchAndDo',
       has => [
           subject_class_name => {
               value => <CLASS NAME>,
               is_constant => 1,
           },
       ],
   };
  ```

### helps (optional)

Overwrite the help\_brief, help\_synopsis and help\_detail methods to provide specific help.  If overwiting the help\_detail method, use call '\_filter\_doc' to get the filter documentation and usage to combine with your specific help.
