Sha256: 605e7c858ca0c79e2c504c07d3927f8f3144df64f5e05e01b62475b416165b7a
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
require 'stamper' require 'stampable' require 'migration_helper' module Ddb module Controller # The Userstamp module, when included into a controller, adds a before filter # (named <tt>set_stamper</tt>) and an after filter (name <tt>reset_stamper</tt>). # These methods assume a couple of things, but can be re-implemented in your # controller to better suite your application. # # See the documentation for <tt>set_stamper</tt> and <tt>reset_stamper</tt> for # specific implementation details. module Userstamp def self.included(base) # :nodoc: base.send :include, InstanceMethods base.before_filter :set_stamper base.after_filter :reset_stamper end module InstanceMethods private # The <tt>set_stamper</tt> method as implemented here assumes a couple # of things. First, that you are using a +User+ model as the stamper # and second that your controller has a <tt>current_user</tt> method # that contains the currently logged in stamper. If either of these # are not the case in your application you will want to manually add # your own implementation of this method to the private section of # the controller where you are including the Userstamp module. def set_stamper User.stamper = self.current_user end # The <tt>reset_stamper</tt> method as implemented here assumes that a # +User+ model is being used as the stamper. If this is not the case then # you will need to manually add your own implementation of this method to # the private section of the controller where you are including the # Userstamp module. def reset_stamper User.reset_stamper end #end private end end end end ActionController::Base.send(:include, Ddb::Controller) if defined?(ActionController)
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
lean_stamper-0.0.3 | lib/userstamp.rb |
lean_stamper-0.0.2 | lib/userstamp.rb |
userstamp-2.0.0 | lib/userstamp.rb |