Skip to content

Commit

Permalink
Add receiver subsection for Duration Arithmetic
Browse files Browse the repository at this point in the history
We prefer an instance of `ActiveSupport::Duration` as a receiver
to calculate relative time like `1.minute.since(created_at)`
  • Loading branch information
aeroastro committed Nov 21, 2023
1 parent 6f56a4a commit 71d5465
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,17 @@ Time.zone.now + 2.days
2.days.from_now
----

Use an instance of `ActiveSupport::Duration` as a receiver to calculate relative time.

[source,ruby]
----
# bad - It's confusing to read
created_at.since(1.minute)
# good
1.minute.since(created_at)
----

== Bundler

=== Dev/Test Gems [[dev-test-gems]]
Expand Down

0 comments on commit 71d5465

Please sign in to comment.