Class: Hotwire::Response::Json::Date
- Inherits:
-
Object
- Object
- Hotwire::Response::Json::Date
- Defined in:
- lib/hotwire/response/json.rb
Overview
Utility class to produce a JSON rendering of dates compatible with what the Wire APIs expect ( a Javascript date object )
Instance Method Summary collapse
-
#initialize(date) ⇒ Date
constructor
A new instance of Date.
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(date) ⇒ Date
Returns a new instance of Date.
72 73 74 |
# File 'lib/hotwire/response/json.rb', line 72 def initialize(date) @date = date end |
Instance Method Details
#to_json(options = nil) ⇒ Object
76 77 78 |
# File 'lib/hotwire/response/json.rb', line 76 def to_json(=nil) @date.nil? ? "" : "new Date(#{@date.year}, #{@date.month-1}, #{@date.day})" end |