Class: Harvest::TimeEntry
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Harvest::TimeEntry
- Includes:
- Model
- Defined in:
- lib/harvest/time_entry.rb
Instance Method Summary collapse
- #as_json(args = {}) ⇒ Object
-
#initialize(args = {}, _ = nil) ⇒ TimeEntry
constructor
A new instance of TimeEntry.
- #spent_at=(date) ⇒ Object
Methods included from Model
Constructor Details
#initialize(args = {}, _ = nil) ⇒ TimeEntry
Returns a new instance of TimeEntry.
9 10 11 12 13 |
# File 'lib/harvest/time_entry.rb', line 9 def initialize(args = {}, _ = nil) args = args.to_hash.stringify_keys self.spent_at = args.delete("spent_at") if args["spent_at"] super end |
Instance Method Details
#as_json(args = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/harvest/time_entry.rb', line 19 def as_json(args = {}) super(args).to_hash.stringify_keys.tap do |hash| hash.update("spent_at" => (spent_at.nil? ? nil : spent_at.xmlschema)) end end |
#spent_at=(date) ⇒ Object
15 16 17 |
# File 'lib/harvest/time_entry.rb', line 15 def spent_at=(date) self["spent_at"] = Date.parse(date.to_s) end |