Skip to content

Instantly share code, notes, and snippets.

@XORwell
Created June 9, 2021 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XORwell/1f01e5dfc26537c4d41a7b179feeefc1 to your computer and use it in GitHub Desktop.
Save XORwell/1f01e5dfc26537c4d41a7b179feeefc1 to your computer and use it in GitHub Desktop.
rails_monkeypatch.rb
class Integer
# @example 15778476.to_duration.in_days
def to_duration
ActiveSupport::Duration.build(self)
end
end
class String
# @example "15778476".to_duration
def to_duration
ActiveSupport::Duration.build(self.to_i)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment