<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/param_protected/constants.rb</filename>
    </added>
    <added>
      <filename>lib/param_protected/controller_modifications.rb</filename>
    </added>
    <added>
      <filename>lib/param_protected/meta_class.rb</filename>
    </added>
    <added>
      <filename>lib/param_protected/protector.rb</filename>
    </added>
    <added>
      <filename>test/protector_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+09/12/2009
+----------
+* Restructured and reorganized.  Now the majority of the work is done in the Protector class.  This minimizes the amount of methods / instance variables that clutter the controllers.
+* The filtering is done in ActionController::Base#params now, instead of as a before filter.  This eliminates the caveat of before filters declared after param_protected/param_accessible calls having access to the unprotected params.
+
 09/11/2009
 ----------
 * Refactored tests to use plugin_test_helper.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,14 @@
 = Summary
 This plugin provides two class methods on &lt;tt&gt;ActiveController::Base&lt;/tt&gt; that filter the &lt;tt&gt;params&lt;/tt&gt; hash for that controller's actions.  You can think of them as the controller analog of &lt;tt&gt;attr_protected&lt;/tt&gt; and &lt;tt&gt;attr_accessible&lt;/tt&gt;.
 
+= Installation
+
+Put in your &lt;tt&gt;environment.rb&lt;/tt&gt; file...
+
+  config.gem &quot;cjbottaro-param_protected&quot;, :lib =&gt; &quot;param_protected&quot;, :source =&gt; &quot;http://gems.github.com&quot;
+  
+Alternatively, just install the gem from the command line and &lt;tt&gt;require &quot;param_protected&quot;&lt;/tt&gt; somewhere in your project.
+
 = Usage
  class YourController &lt; ActiveController::Base
    param_protected &lt;param_name&gt; &lt;options&gt;
@@ -29,13 +37,13 @@ Any of these combinations should work.
  param_accessible :client_id, :except =&gt; [:your_action, :my_action]
 
 == Nested Params
-You can use combinations of arrays and hashes to specify nested params, much the same way ActiveRecord::Base#find's
-:include argument works.
+You can use combinations of arrays and hashes to specify nested params, much the same way &lt;tt&gt;ActiveRecord::Base#find&lt;/tt&gt;'s
+&lt;tt&gt;:include&lt;/tt&gt; argument works.
  param_accessible [:account_name, { :user =&gt; [:first_name, :last_name, :address =&gt; [:street, :city, :state]] }]
  param_protected [:id, :password, { :user =&gt; [:id, :password] }]
 
-== Caveats
-Both &lt;tt&gt;param_protected&lt;/tt&gt; and &lt;tt&gt;param_accessible&lt;/tt&gt; are really just calls to &lt;tt&gt;prepend_before_filter&lt;/tt&gt;.  Thus any methods in your filter chain that run before either of these methods will have full access to the &lt;em&gt;unprotected&lt;/em&gt; &lt;tt&gt;params&lt;/tt&gt; Hash.
+= How does it work?
+It does an &lt;tt&gt;alias_method_chain&lt;/tt&gt; on &lt;tt&gt;ActionController::Base#params&lt;/tt&gt; that filters (and caches) the params.  You can get the unfiltered, pristine params by calling &lt;tt&gt;ActionController::Base#params_without_protection&lt;/tt&gt;.
 
 = Author
 Christopher J. Bottaro
\ No newline at end of file</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -31,6 +31,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'rdoc'
   rdoc.title    = 'ParamProtected'
   rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
-  rdoc.rdoc_files.include('README')
+  rdoc.rdoc_files.include('README.rdoc')
   rdoc.rdoc_files.include('lib/**/*.rb')
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,121 +1,6 @@
-# paramProtected
+require &quot;param_protected/meta_class&quot;
+require &quot;param_protected/constants&quot;
+require &quot;param_protected/protector&quot;
+require &quot;param_protected/controller_modifications&quot;
 
-module Cjbottaro
-
-  module ParamProtected
-
-    def self.extended(klass)
-      klass.class_eval do
-        include InstanceMethods
-      end
-    end
-    
-    def param_protected(params, actions = nil)
-      Helpers.init_storage(self)
-      params  = Helpers.normalize_params(params)
-      actions = Helpers.normalize_actions(actions)
-      self.pp_protected &lt;&lt; [params, actions]
-      skip_before_filter    :do_param_protected
-      prepend_before_filter :do_param_protected
-    end
-    
-    def param_accessible(params, actions = nil)
-      Helpers.init_storage(self)
-      params  = Helpers.normalize_params(params)
-      actions = Helpers.normalize_actions(actions)
-      self.pp_accessible &lt;&lt; [params, actions]
-      skip_before_filter    :do_param_accessible
-      prepend_before_filter :do_param_accessible
-    end
-    
-    module InstanceMethods
-    
-      def do_param_protected
-        self.class.pp_protected.each do |protected_params, actions|
-          scope, actions = actions.first, actions[1..-1]
-          Helpers.do_param_protected(protected_params, self.params) \
-            if Helpers.action_matches?(scope, actions, self.action_name)
-        end
-      end
-      
-      def do_param_accessible
-        self.class.pp_accessible.each do |accessible_params, actions|
-          scope, actions = actions.first, actions[1..-1]
-          Helpers.do_param_accessible(accessible_params, self.params) \
-            if Helpers.action_matches?(scope, actions, self.action_name)
-        end
-      end
-      
-    end
-    
-    module Helpers
-      
-      def self.init_storage(klass)
-        class &lt;&lt; klass
-          attr_accessor :pp_protected, :pp_accessible
-        end
-        klass.pp_protected  = [] if klass.pp_protected.nil?
-        klass.pp_accessible = [] if klass.pp_accessible.nil?
-      end
-      
-      def self.normalize_params(params, params_out = {})
-        if params.instance_of?(Array)
-          params.each{ |param| normalize_params(param, params_out) }
-        elsif params.instance_of?(Hash)
-          params.each do |k, v|
-            k = k.to_s
-            params_out[k] = {}
-            normalize_params(v, params_out[k])
-          end
-        else
-          params_out[params.to_s] = nil
-        end
-        params_out
-      end
-      
-      def self.normalize_actions(actions)
-        error_message = &quot;invalid actions, use :only =&gt; ..., :except =&gt; ..., or nil&quot;
-        return [:except, nil] if actions.blank?
-        raise ArgumentError, error_message unless actions.instance_of?(Hash)
-        raise ArgumentError, error_message unless actions.length == 1
-        raise ArgumentError, error_message unless [:only, :except].include?(actions.keys.first)
-        
-        scope, actions = actions.keys.first, actions.values.first
-        actions = [actions] unless actions.instance_of?(Array)
-        actions = actions.collect{ |action| action.to_s }
-        [scope, *actions]
-      end
-      
-      def self.action_matches?(scope, valid_actions, action_name)
-        if scope == :only
-          valid_actions.include?(action_name)
-        elsif scope == :except
-          !valid_actions.include?(action_name)
-        else
-          raise ArgumentError, &quot;unexpected scope (#{scope}), expected :only or :except&quot;
-        end
-      end
-      
-      def self.do_param_protected(protected_params, params)
-        return unless params.kind_of?(Hash)
-        return if protected_params.nil?
-        params.delete_if{ |k, v| protected_params.has_key?(k) and protected_params[k].nil? }
-        params.each{ |k, v| do_param_protected(protected_params[k], v) }
-        params
-      end
-      
-      def self.do_param_accessible(accessible_params, params)
-        return unless params.kind_of?(Hash)
-        return if accessible_params.nil?
-        params.delete_if{ |k, v| !accessible_params.has_key?(k) }
-        params.each{ |k, v| do_param_accessible(accessible_params[k], v) }
-        params
-      end
-      
-    end
-    
-  end
-  
-end
-
-ActionController::Base.extend Cjbottaro::ParamProtected
\ No newline at end of file
+ActionController::Base.extend(ParamProtected::ControllerModifications)
\ No newline at end of file</diff>
      <filename>lib/param_protected.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/app_root/log/in_memory.log</filename>
    </removed>
    <removed>
      <filename>test/helpers_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>4cab0dc5e68e8c6d20d24a3fc8f258bfd860b80a</id>
    </parent>
  </parents>
  <author>
    <name>cjbottaro</name>
    <email>cjbottaro@alumni.cs.utexas.edu</email>
  </author>
  <url>http://github.com/cjbottaro/param_protected/commit/1f4327a1cfda116d47db96406d83a0fba870f459</url>
  <id>1f4327a1cfda116d47db96406d83a0fba870f459</id>
  <committed-date>2009-09-12T12:43:51-07:00</committed-date>
  <authored-date>2009-09-12T12:43:51-07:00</authored-date>
  <message>Refactored bulk of the implementation into the Protector class.
Moved filtering of params from a before_filter implementation to alias method chaining ActionController::Base#params.</message>
  <tree>83e2d3ae06a2e5e17f06cc5b7407d45be15370e6</tree>
  <committer>
    <name>cjbottaro</name>
    <email>cjbottaro@alumni.cs.utexas.edu</email>
  </committer>
</commit>
