Class: DatedCost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- DatedCost
- 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
-
#temp_id ⇒ Object
Returns the value of attribute temp_id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#temp_id ⇒ Object
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_scope ⇒ Object
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(={}) {}.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!() end end |