Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Docs: signatures for methods returning relations
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredbeck authored Oct 25, 2019
1 parent f014e70 commit a0907b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ Wizard.all.pluck_to_tstruct(TA[WizardStruct].new) # T::Array[WizardStruct]

This method is based on [pluck_to_hash](https://github.com/girishso/pluck_to_hash) gem.

### How to write signatures for methods returning relations

```ruby
# app/queries/bacon_query.rb
class BaconQuery
sig { returns(ActiveRecord::Relation) }
def chunky
Bacon.where(chunky: true)
end
end
```

It is not currently possible to use `returns(Bacon::ActiveRecord_Relation)`. It will raise a `NameError: uninitialized constant Bacon::ActiveRecord_Relation`.

## Extending Model Generation Task with Custom Plugins

`sorbet-rails` support a customizable plugin system that you can use to generate additional RBI for each model. This will be useful to generate RBI for methods dynamically added by gems or private concerns. If you write plugins for public gems, please feel free to contribute it to this repo.
Expand Down

0 comments on commit a0907b5

Please sign in to comment.