Module: ActsAsFootprintable::Footprintable
- Defined in:
- lib/acts_as_footprintable/footprintable.rb
Class Method Summary collapse
Instance Method Summary collapse
- #footprint_count ⇒ Object
- #footprint_count_between(range) ⇒ Object
- #leave_footprints(footprinter) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/acts_as_footprintable/footprintable.rb', line 5 def self.included(base) base.class_eval do has_many :footprints, class_name: 'ActsAsFootprintable::Footprint', as: :footprintable, dependent: :destroy do def footprinters includes(:footprinter).map(&:footprinter) end end end end |
Instance Method Details
#footprint_count ⇒ Object
20 21 22 |
# File 'lib/acts_as_footprintable/footprintable.rb', line 20 def footprint_count footprints.count end |
#footprint_count_between(range) ⇒ Object
24 25 26 |
# File 'lib/acts_as_footprintable/footprintable.rb', line 24 def footprint_count_between(range) footprints.where(created_at: range).count end |
#leave_footprints(footprinter) ⇒ Object
15 16 17 18 |
# File 'lib/acts_as_footprintable/footprintable.rb', line 15 def leave_footprints(footprinter) footprint = ActsAsFootprintable::Footprint.new(footprintable: self, footprinter: footprinter) footprint.save end |