Class: DatedCost

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
E9::ActiveRecord::TimeScopes, E9Rails::ActiveRecord::Initialization
Defined in:
app/models/dated_cost.rb

Overview

Encapulates a Cost and a Date, used to track costs by date so sums for date ranges can be generated.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#temp_idObject

Returns the value of attribute temp_id.



14
15
16
# File 'app/models/dated_cost.rb', line 14

def temp_id
  @temp_id
end

Class Method Details

.default_scopeObject



16
17
18
# File 'app/models/dated_cost.rb', line 16

def self.default_scope
  order('dated_costs.created_at ASC')
end

Instance Method Details

#as_json(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/dated_cost.rb', line 20

def as_json(options={})
  {}.tap do |hash|
    hash[:id]            = self.id
    hash[:cost]          = self.cost
    hash[:date]          = self.date
    hash[:costable_type] = self.costable_type.try(:underscore)
    hash[:costable_id]   = self.costable_id
    hash[:errors]        = self.errors

    hash.merge!(options)
  end
end