This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddTeacherToSite < TypedMutation | |
class Args < T::Struct | |
const :site, Site | |
const :teacher, Teacher | |
end | |
def policy | |
# pass the privacy policy required | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddTeacherToSite < Mutation | |
def required_arguments | |
[ | |
model_or_id(:site, Site), | |
model_or_id(:teacher, Teacher), | |
] | |
end | |
def policy | |
# list the privacy policy required for this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method `to_i` does not exist on `Array` component of | |
`T.any(String, Integer, T::Array[Integer])` | |
4 |hash = str_or_int_or_array.to_i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str_or_int_or_array = ["1", 2, [3]].sample | |
hash = str_or_int_or_array.to_i | |
# NoMethodError: method to_i doesn't exist on `Array` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# typed: true | |
extend T::Sig | |
sig { params(name: String).returns(Integer) } | |
def main(name) | |
puts "Hello, #{name}!" | |
end | |
main("Sorbet") # ok! | |
main() # error: Not enough arguments provided |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# typed: strict | |
class MyCoolController < ApplicationController | |
class MyActionParams < T::Struct | |
const :id, T.nilable(Integer) | |
const :show, T.nilable(T::Boolean) | |
const :wands, T::Array[Integer] | |
end | |
sig { void } | |
def my_action | |
typed_params = TypedParams[MyActionParams].new.extract!(params) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mailer.rb | |
class HogwartsAcceptanceMailer < ApplicationMailer | |
extend T::Sig | |
sig { params(student: Wizard).void } | |
def notify(student) | |
# TODO: send an owl | |
end | |
def notify_retry(student) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- generated routes.rbi | |
# Sigs for route /test/index(.:format) | |
sig { params(args: T.untyped, kwargs: T.untyped).returns(String) } | |
def test_index_path(*args, **kwargs); end | |
sig { params(args: T.untyped, kwargs: T.untyped).returns(String) } | |
def test_index_url(*args, **kwargs); end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - example wizard.rbi | |
class Wizard < ApplicationRecord | |
sig { returns(T.nilable(String)) } | |
def name; end | |
sig { returns(T.nilable(::Wand)) } | |
def wand; end | |
sig { returns(::SpellBook::ActiveRecord_Associations_CollectionProxy) } | |
def spell_books; end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- wizard.rbi | |
class Wizard | |
sig { params(id: String).returns(Wizard)) } | |
def self.find(id); end | |
end |
NewerOlder