<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+* 0.03 - 04/28/2008
+  - Added :only_if_logged_in? key since logged_in? can't be tested via :if (scoping)
+  - Added generator option --library-only to allow for &quot;safe&quot; library updating
+  - Documented and enabled --skip-migration option
+
 * 0.02 - 04/25/2008
   - Fixed documentation problems (require_foo instead of authorize_foo leftovers)
   - Correctly failing users who aren't logged in for all conditions</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,10 @@ To begin using restful-authorization, run:
 where role is your intended Role model name and user is the name of your
 User model in restful_authentication.
 
+The generator takes two additional options:
+  --skip-migration only skips the migration
+  --library_only only regenerates the library
+
 Syntax
 ======
 
@@ -75,6 +79,10 @@ Individual authorization requirements can be limited via a number of keys:
   * Restrict only the create and new actions
     :only =&gt; [:create, :new]
   
+  * Restrict only the create and new actions for users who are logged_in?
+    These will continue to be accessible to users who aren't logged_in?
+    :only_if_logged_in? =&gt; [:create, :new]
+  
   * Restrict all actions except index and show  
     :except =&gt; [:index, :show]
   </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 require( File.join( File.dirname(__FILE__), &quot;../authorized_generator_helpers&quot; ))
 
 class AuthorizedGenerator &lt; Rails::Generator::NamedBase
+  default_options :library_only =&gt; false,
+                  :skip_migration =&gt; false
   
   include AuthorizedGeneratorHelpers
   
@@ -23,15 +25,19 @@ class AuthorizedGenerator &lt; Rails::Generator::NamedBase
   
   def manifest
     record do |m|
-      modify_or_add_user_fixtures(m)
-      add_roles_and_join_table_fixtures(m)
+      unless options[:library_only]
+        modify_or_add_user_fixtures(m)
+        add_roles_and_join_table_fixtures(m)
       
-      add_method_to_user_model(m)
+        add_method_to_user_model(m)
+      
+        add_role_model(m)
+        add_dependencies_to_application_rb
+        add_migration(m) unless options[:skip_migration]
+      end
       
-      add_role_model(m)
-      add_dependencies_to_application_rb
       add_authorized_system(m)
-      add_migration(m) unless options[:skip_migration]
+
     end
   end
   
@@ -145,4 +151,13 @@ EOF
       &quot;Usage: #{$0} authorized RoleModelName [TargetUserModelName]&quot;
     end
 
+
+    def add_options!(opt)
+      opt.separator ''
+      opt.separator 'Options:'
+      opt.on(&quot;--skip-migration&quot;, 
+             &quot;Don't generate a migration file for this model&quot;) { |v| options[:skip_migration] = v }
+      opt.on(&quot;--library-only&quot;, 
+             &quot;Only regenerates the library file&quot;) { |v| options[:library_only] = true }
+    end
 end
\ No newline at end of file</diff>
      <filename>generators/authorized/authorized_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,11 @@ module AuthorizedSystem
     #
     # Valid options
     #
-    #   * :only    - authorization is only required for these actions
-    #   * :except  - authorization is required for all other actions
-    #   * :if      - a Proc or a string to evaluate; the authorization is required if it returns true
-    #   * :unless  - the inverse of :if
+    #   * :only               - authorization is only required for these actions
+    #   * :only_if_logged_in? - authorization is only required for these actions if the user is logged_in?
+    #   * :except             - authorization is required for all other actions
+    #   * :if                 - a Proc or a string to evaluate; the authorization is required if it returns true
+    #   * :unless             - the inverse of :if
     #
     #   * :redirect_url - takes a named route as a symbol (:new_example_path), string &quot;/example/new&quot;,
     #     or hash { :controller =&gt; &quot;example&quot;, :action =&gt; &quot;new&quot; }
@@ -48,7 +49,7 @@ module AuthorizedSystem
     #   given status. If no :render_url is specified, it renders a blank page with the status code given.
     #        
     def require_authorization(type, values, options = {})
-      options.assert_valid_keys(:if, :unless, :only, :except, :redirect_url, :render_url, :status)
+      options.assert_valid_keys(:if, :unless, :only, :only_if_logged_in?, :except, :redirect_url, :render_url, :status)
       
       # only declare the before filter once
       unless @before_filter_declared ||= false
@@ -95,6 +96,10 @@ module AuthorizedSystem
         options = requirement[:options]
     
         # handle the restriction keys associated with this requirement
+        if options.has_key?(:only_if_logged_in?)
+          next unless (options[:only_if_logged_in?].include?( (params[:action]||&quot;index&quot;).to_sym) and &lt;%= users_name %&gt;)
+        end
+
         if options.has_key?(:only)
           next unless options[:only].include?( (params[:action]||&quot;index&quot;).to_sym)
         end</diff>
      <filename>generators/authorized/templates/authorized_system.rb.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3ff1d85fb8615755b041cdf835452f9b4be1ffe9</id>
    </parent>
  </parents>
  <author>
    <name>Jonathan Barket</name>
    <email>jbarket@jonathan-barkets-macbook-pro.local</email>
  </author>
  <url>http://github.com/jbarket/restful-authorization/commit/f8bf32a831eb66bcfb7f38d3e139c7ccb1443353</url>
  <id>f8bf32a831eb66bcfb7f38d3e139c7ccb1443353</id>
  <committed-date>2008-04-28T12:25:48-07:00</committed-date>
  <authored-date>2008-04-28T12:25:48-07:00</authored-date>
  <message>Added :only_if_logged_in? and a few generator options</message>
  <tree>94d601a3c04efe7be1c3164e047543f69c521e09</tree>
  <committer>
    <name>Jonathan Barket</name>
    <email>jbarket@jonathan-barkets-macbook-pro.local</email>
  </committer>
</commit>
