Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 922 Bytes

compiler_activestorage.md

File metadata and controls

34 lines (25 loc) · 922 Bytes

ActiveStorage

Tapioca::Dsl::Compilers::ActiveStorage decorates RBI files for subclasses of ActiveRecord::Base that declare one or many attachments.

For example, with the following ActiveRecord::Base subclass:

class Post < ApplicationRecord
 has_one_attached :photo
 has_many_attached :blogs
end

this compiler will produce the RBI file post.rbi with the following content:

# typed: strong

class Post
  sig { returns(ActiveStorage::Attached::Many) }
  def blogs; end

  sig { params(attachable: T.untyped).returns(T.untyped) }
  def blogs=(attachable); end

  sig { returns(ActiveStorage::Attached::One) }
  def photo; end

  sig { params(attachable: T.untyped).returns(T.untyped) }
  def photo=(attachable); end
end