Module: Piggybak::FormattedChanges
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/formatted_changes.rb
Instance Method Summary collapse
Instance Method Details
#formatted_changes ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/formatted_changes.rb', line 20 def formatted_changes text = "#{self.class.to_s.gsub(/Piggybak::/, '')} ##{self.id} changes:<br />" self.changes.each do |k, v| if !["updated_at", "id", "billing_address_id", "shipping_address_id", "created_at", "sellable_id", "line_item_type", "unit_price", "sort"].include?(k) if v[0].is_a?(BigDecimal) text += "#{k}: $#{format("%.2f", v[0])} to $#{format("%.2f", v[1])}<br />" else text += "#{k}: #{v[0]} to #{v[1]}<br />" end end end return text end |
#new_destroy_changes(type) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/formatted_changes.rb', line 5 def new_destroy_changes(type) text = "#{self.class.to_s.gsub(/Piggybak::/, '')} ##{self.id} #{type}:<br />" self.attributes.each do |k, v| if !["updated_at", "created_at", "id", "order_id", "billing_address_id", "shipping_address_id", "sellable_id", "line_item_type", "unit_price", "sort"].include?(k) if v.is_a?(BigDecimal) text += "#{k}: $#{format("%.2f", v)}<br />" else text += "#{k}: #{v}<br />" end end end return text end |