Sha256: cc9fafde36dc57dbf5092aa5d51df01441e1fe80980587920721ee1ae513ec09

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

# Destroy Context

Destroy sets up an object using the build functionality, and then attempts to save it to the data source.

Destroy does the following:

- Find a model
- Destroy the model

##### Example

```ruby
class PeopleContext
  include SnFoil::CRUD::DestroyContext

  searcher PeopleSearcher
  policy PersonPolicy
  model Person
end
```

### Required Class Definitions

- Searcher
- Policy
- Model

### Primary Action
Destroys the model.
### Intervals (in order)

<table>
  <thead>
    <th>name</th>
    <th>description</th>
    <th>pre-defined functions</th>
  </thead>

  <tbody>
    <tr>
      <td>setup</td>
      <td>Shared by all CRUD actions</td>
      <td></td>
    </tr>
    <tr>
      <td>setup_change</td>
      <td>Shared by Create, Update, and Destroy actions</td>
      <td></td>
    </tr>
    <tr>
      <td>setup_destroy</td>
      <td></td>
      <td>Finds the model</td>
    </tr>
    <tr>
      <td>before_change</td>
      <td>Shared by Create, Update, and Destroy actions</td>
      <td></td>
    </tr>
    <tr>
      <td>before_destroy</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>after_change_success</td>
      <td>Shared by Create, Update, and Destroy actions</td>
      <td></td>
    </tr>
    <tr>
      <td>after_destroy_success</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>after_change_failure</td>
      <td>Shared by Create, Update, and Destroy actions</td>
      <td></td>
    </tr>
    <tr>
      <td>after_destroy_failure</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>after_change</td>
      <td>Shared by Create, Update, and Destroy actions</td>
      <td></td>
    </tr>
    <tr>
      <td>after_destroy</td>
      <td></td>
      <td></td>
    </tr>
  </tbody>
</table>

### ORM Adapter Requirements

The following methods must be defined on the ORM adapter to use the destroy context

- `destroy`

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
snfoil-1.1.1 docs/destroy-context.md
snfoil-1.1.0 docs/destroy-context.md
snfoil-1.0.1 docs/destroy-context.md
snfoil-1.0.0 docs/destroy-context.md