Module: Impressionist::Impressionable
- Extended by:
- ActiveSupport::Concern
- Includes:
- IsImpressionable
- Defined in:
- app/models/impressionist/impressionable.rb,
lib/impressionist/models/mongoid/impressionist/impressionable.rb,
lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb,
lib/impressionist/models/active_record/impressionist/impressionable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #impressionable? ⇒ Boolean
-
#impressionist_count(options = {}) ⇒ Object
Overides impressionist_count in order to provide mongoid compability.
- #update_impressionist_counter_cache ⇒ Object
Instance Method Details
#impressionable? ⇒ Boolean
56 57 58 |
# File 'app/models/impressionist/impressionable.rb', line 56 def impressionable? true end |
#impressionist_count(options = {}) ⇒ Object
Overides impressionist_count in order to provide mongoid compability
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/impressionist/impressionable.rb', line 31 def impressionist_count(={}) # Uses these options as defaults unless overridden in options hash .reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now) # If a start_date is provided, finds impressions between then and the end_date. Otherwise returns all impressions imps = [:start_date].blank? ? impressions : impressions.where("created_at >= ? and created_at <= ?", [:start_date], [:end_date]) if [:message] imps = imps.where("impressions.message = ?", [:message]) end # Count all distinct impressions unless the :all filter is provided. distinct = [:filter] != :all if Rails::VERSION::MAJOR == 4 distinct ? imps.select([:filter]).distinct.count : imps.count else distinct ? imps.count([:filter], :distinct => true) : imps.count end end |
#update_impressionist_counter_cache ⇒ Object
51 52 53 54 |
# File 'app/models/impressionist/impressionable.rb', line 51 def update_impressionist_counter_cache slave = Impressionist::UpdateCounters.new(self) slave.update end |