Skip to content

Commit

Permalink
Plain object, override to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonn-webster committed Feb 8, 2024
1 parent 8de3926 commit 260f5a3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions motion/duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module MotionSupport
# Time#advance, respectively. It mainly supports the methods on Numeric.
#
# 1.month.ago # equivalent to Time.now.advance(months: -1)
class Duration < BasicObject
class Duration
attr_accessor :value, :parts

def initialize(value, parts) #:nodoc:
Expand Down Expand Up @@ -79,7 +79,11 @@ def as_json(options = nil) #:nodoc:
to_i
end

protected
def to_json
as_json.to_json
end

protected

def sum(sign, time = ::Time.now) #:nodoc:
parts.inject(time) do |t,(type,number)|
Expand Down

0 comments on commit 260f5a3

Please sign in to comment.