Module: Impressionist::Impressionable::ClassMethods

Defined in:
app/models/impressionist/impressionable.rb,
lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#impressionist_cache_optionsObject

Returns the value of attribute impressionist_cache_options


6
7
8
# File 'app/models/impressionist/impressionable.rb', line 6

def impressionist_cache_options
  @impressionist_cache_options
end

Instance Method Details

#counter_caching?Boolean

Returns:

  • (Boolean)

24
25
26
27
# File 'app/models/impressionist/impressionable.rb', line 24

def counter_caching?
    ::ActiveSupport::Deprecation.warn("#counter_caching? is deprecated; please use #impressionist_counter_caching? instead")
    impressionist_counter_caching?
end

#impressionist_counter_cache_optionsObject


14
15
16
17
# File 'app/models/impressionist/impressionable.rb', line 14

def impressionist_counter_cache_options
  @impressionist_cache_options ||= {}
  @impressionist_cache_options.reverse_merge!(DEFAULT_CACHE)
end

#impressionist_counter_caching?Boolean

asks impressionable entity whether or not it is counter_caching

Returns:

  • (Boolean)

20
21
22
# File 'app/models/impressionist/impressionable.rb', line 20

def impressionist_counter_caching?
  impressionist_counter_cache_options[:counter_cache]
end

#is_impressionable(options = {}) ⇒ Object


9
10
11
12
13
14
15
# File 'lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb', line 9

def is_impressionable(options={})
  many(:impressions,
  :as => :impressionable,
  :dependent => :delete_all)

  @impressionist_cache_options = options
end