Sha256: 472d5799a9a506e4b596e7b7720f28459446cbaf94dc4e9ddd0bd83c6c225594

Contents?: true

Size: 438 Bytes

Versions: 2

Compression:

Stored size: 438 Bytes

Contents

module Cohortly
  class UserCohort
    include MongoMapper::Document
    key :user_ids, Array
    key :name,      String
    key :_type,    String    
    timestamps!
    
    def self.intersect(cohorts)
      cohorts.inject(cohorts.first.user_ids) { |user_ids, cohort| user_ids & cohort.user_ids }
    end

    def self.union(cohorts)
      cohorts.inject([]) { |user_ids, cohort| user_ids | cohort.user_ids }
    end    
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cohortly-0.0.93 app/models/cohortly/user_cohort.rb
cohortly-0.0.92 app/models/cohortly/user_cohort.rb