class Tapioca::Dsl::Compilers::ActiveSupportTimeExt
: [ConstantType = singleton(::Time)]
“‘
end
end
def current; end
sig { returns(::Time) }
class << self
class Time
“`rbi
whereas if `Time.zone` and `config.time_zone` are not set, it will produce:
“`
end
end
def current; end
sig { returns(::ActiveSupport::TimeWithZone) }
class << self
class Time
“`rbi
this compiler will produce the following RBI file:
“`
config.time_zone = “UTC”
“`ruby
For an application that is configured with:
an instance of `ActiveSupport::TimeWithZone`, otherwise it will return an instance of `Time`.
If `Time.zone` or `config.time_zone` are set, then the `Time.current` method will be defined as returning
defined by [Active Support’s Time extensions](api.rubyonrails.org/classes/Time.html).
‘Tapioca::Dsl::Compilers::ActiveSupportTimeExt` generates an RBI file for the `Time#current` method
def decorate
@override
def decorate return unless constant.respond_to?(:zone) root.create_path(constant) do |mod| return_type = if ::Time.zone "::ActiveSupport::TimeWithZone" else "::Time" end mod.create_method("current", return_type: return_type, class_method: true) end end
def gather_constants
@override
def gather_constants [::Time] end