class TicketSharing::Time
Attributes
value[R]
Public Class Methods
new(value)
click to toggle source
# File lib/ticket_sharing/time.rb, line 8 def initialize(value) case value when ::Time, nil @value = value when String @value = ::Time.parse(value.dup) else raise "Invalid value provided for requested_at" end end
Public Instance Methods
as_json(_options = {})
click to toggle source
# File lib/ticket_sharing/time.rb, line 19 def as_json(_options = {}) @value ? @value.strftime('%Y-%m-%d %H:%M:%S %z') : nil end
to_json(_options = {})
click to toggle source
# File lib/ticket_sharing/time.rb, line 23 def to_json(_options = {}) JsonSupport.encode(as_json) end
to_time()
click to toggle source
Support method to play well with active record
# File lib/ticket_sharing/time.rb, line 28 def to_time value end