Module: ImpressionistController::InstanceMethods
- Defined in:
- app/controllers/impressionist_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #impressionist(obj, message = nil, opts = {}) ⇒ Object
- #impressionist_app_filter ⇒ Object
- #impressionist_subapp_filter(opts = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
11 12 13 |
# File 'app/controllers/impressionist_controller.rb', line 11 def self.included(base) base.before_filter :impressionist_app_filter end |
Instance Method Details
#impressionist(obj, message = nil, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/impressionist_controller.rb', line 15 def impressionist(obj,=nil,opts={}) if should_count_impression?(opts) if obj.respond_to?("impressionable?") if unique_instance?(obj, opts[:unique]) obj.impressions.create(associative_create_statement({:message => })) end else # we could create an impression anyway. for classes, too. why not? raise "#{obj.class.to_s} is not impressionable!" end end end |
#impressionist_app_filter ⇒ Object
28 29 30 |
# File 'app/controllers/impressionist_controller.rb', line 28 def impressionist_app_filter @impressionist_hash = Digest::SHA2.hexdigest(Time.now.to_f.to_s+rand(10000).to_s) end |
#impressionist_subapp_filter(opts = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/impressionist_controller.rb', line 32 def impressionist_subapp_filter(opts = {}) if should_count_impression?(opts) actions = opts[:actions] actions.collect!{|a|a.to_s} unless actions.blank? if (actions.blank? || actions.include?(action_name)) && unique?(opts[:unique]) Impression.create(direct_create_statement) end end end |