Class: Harvest::Expense
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Harvest::Expense
- Includes:
- Model
- Defined in:
- lib/harvest/expense.rb
Instance Method Summary (collapse)
- - (Object) as_json(args = {})
-
- (Expense) initialize(args = {}, _ = nil)
constructor
A new instance of Expense.
- - (Object) spent_at=(date)
Methods included from Model
Constructor Details
- (Expense) initialize(args = {}, _ = nil)
A new instance of Expense
9 10 11 12 13 |
# File 'lib/harvest/expense.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 24 25 |
# File 'lib/harvest/expense.rb', line 19 def as_json(args = {}) super(args).to_hash.stringify_keys.tap do |hash| hash[json_root].update("spent_at" => (spent_at.nil? ? nil : spent_at.xmlschema)) hash[json_root].delete("has_receipt") hash[json_root].delete("receipt_url") end end |
- (Object) spent_at=(date)
15 16 17 |
# File 'lib/harvest/expense.rb', line 15 def spent_at=(date) self["spent_at"] = Date.parse(date.to_s) end |