Module: CohortAnalysis::ActiveRecordRelationInstanceMethods
- Defined in:
- lib/cohort_analysis/active_record_relation_instance_methods.rb
Instance Method Summary collapse
-
#cohort(characteristics, options = {}) ⇒ Arel::SelectManager
A select manager without any projections.
- #cohort_relation(characteristics, options = {}) ⇒ ActiveRecord::Relation
Instance Method Details
#cohort(characteristics, options = {}) ⇒ Arel::SelectManager
Note:
This doesn’t return a ActiveRecord::Relation
, so you can’t just call count.
Returns A select manager without any projections.
11 12 13 14 15 16 |
# File 'lib/cohort_analysis/active_record_relation_instance_methods.rb', line 11 def cohort(characteristics, = {}) select_manager = arel.clone select_manager.projections = [] select_manager.where Strategy.create(select_manager, characteristics, ) select_manager end |
#cohort_relation(characteristics, options = {}) ⇒ ActiveRecord::Relation
Note:
Won’t work properly unless it’s the last constraint in your chain.
25 26 27 |
# File 'lib/cohort_analysis/active_record_relation_instance_methods.rb', line 25 def cohort_relation(characteristics, = {}) where Strategy.create(arel, characteristics, ) end |