Class: Cashboard::TimeEntry
- Inherits:
-
Base
- Object
- OpenStruct
- TypecastedOpenStruct
- Struct
- Base
- Cashboard::TimeEntry
- Defined in:
- lib/cashboard/time_entry.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#has_been_invoiced? ⇒ Boolean
If a TimeEntry has no invoice_line_item_id set, then it hasn’t been included on an invoice.
-
#toggle_timer ⇒ Object
Starts or stops timer depending on its current state.
Methods inherited from Base
authenticate, clear_authentication, create, #delete, #links, list, new_from_url, #to_xml, #update
Methods inherited from Struct
Methods inherited from TypecastedOpenStruct
Constructor Details
This class inherits a constructor from Cashboard::Struct
Instance Method Details
#has_been_invoiced? ⇒ Boolean
If a TimeEntry has no invoice_line_item_id set, then it hasn’t been included on an invoice.
40 41 42 |
# File 'lib/cashboard/time_entry.rb', line 40 def has_been_invoiced? !self.invoice_line_item_id.blank? end |
#toggle_timer ⇒ Object
Starts or stops timer depending on its current state.
Will return an object of Cashboard::Struct if another timer was stopped during this toggle operation.
Will return nil if no timer was stopped.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cashboard/time_entry.rb', line 20 def toggle_timer = self.class.() .merge!({:body => self.to_xml}) response = self.class.put(self.links[:toggle_timer], ) # Raise special errors if not a success self.class.check_status_code(response) # Re-initialize ourselves with information from response initialize(response.parsed_response) if self.stopped_timer stopped_timer = Cashboard::Struct.new(self.stopped_timer) end stopped_timer || nil end |