Class: Harvest::TimeEntry

Inherits:
Hashie::Mash
  • Object
show all
Includes:
Model
Defined in:
lib/harvest/time_entry.rb

Instance Method Summary (collapse)

Methods included from Model

included

Constructor Details

- (TimeEntry) initialize(args = {}, _ = nil)

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

- (Object) as_json(args = {})



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

- (Object) spent_at=(date)



15
16
17
# File 'lib/harvest/time_entry.rb', line 15

def spent_at=(date)
  self["spent_at"] = Date.parse(date.to_s)
end