Skip to content

Commit

Permalink
Describe sorbet and tapioca support in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
Verseth committed May 13, 2024
1 parent c2d0796 commit c64dd34
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This addon to the [shale](https://github.com/kgiszczak/shale) Ruby gem adds a simple yet powerful builder DSL.

It also adds support for sorbet and tapioca in shale.
This gem includes a custom tapioca DSL compiler designed for shale.

## Installation

Install the gem and add to the application's Gemfile by executing:
Expand Down Expand Up @@ -48,7 +51,11 @@ class Amount < Shale::Mapper
include Shale::Builder

attribute :value, Shale::Type::Float
attribute :currency, Shale::Type::String
attribute :currency, Shale::Type::String, doc: <<~DOC
This is some custom documentation that can be used by sorbet.
It will be used by the tapioca DSL compiler
to generate the RBI documentation for this attribute.
DOC
end
```

Expand All @@ -67,6 +74,36 @@ amount = Amount.build do |a|
end
```

If you use sorbet and run `bundle exec tapioca dsl` you'll get the following RBI file.

```rb
# typed: true

class Amount
include ShaleAttributeMethods

module ShaleAttributeMethods
sig { returns(T.nilable(Float)) }
def value; end

sig { params(value: T.nilable(Float)).returns(T.nilable(Float)) }
def value=(value); end

# This is some custom documentation that can be used by sorbet.
# It will be used by the tapioca DSL compiler
# to generate the RBI documentation for this attribute.
sig { returns(T.nilable(String)) }
def currency; end

# This is some custom documentation that can be used by sorbet.
# It will be used by the tapioca DSL compiler
# to generate the RBI documentation for this attribute.
sig { params(value: T.nilable(String)).returns(T.nilable(String)) }
def currency=(value); end
end
end
```
### Building nested objects
It's kind of pointless when you've got a flat structure.
Expand Down

0 comments on commit c64dd34

Please sign in to comment.