module ActsAsFootprintable::Footprintable

Public Class Methods

included(base) click to toggle source
# 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

Public Instance Methods

footprint_count() click to toggle source
# File lib/acts_as_footprintable/footprintable.rb, line 20
def footprint_count
  footprints.count
end
footprint_count_between(range) click to toggle source
# File lib/acts_as_footprintable/footprintable.rb, line 24
def footprint_count_between(range)
  footprints.where(created_at: range).count
end
footprinters() click to toggle source
# File lib/acts_as_footprintable/footprintable.rb, line 8
def footprinters
  includes(:footprinter).map(&:footprinter)
end
leave_footprints(footprinter) click to toggle source
# File lib/acts_as_footprintable/footprintable.rb, line 15
def leave_footprints(footprinter)
  footprint = ActsAsFootprintable::Footprint.new(footprintable: self, footprinter: footprinter)
  footprint.save
end