<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-Copyright (c) 2006-08 Relevance, LLC (http://relevancellc.com, http://streamlinedframework.org)
+Copyright (c) 2006-08 Relevance, Inc. (http://relevancellc.com, http://streamlinedframework.org)
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction,
 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished</diff>
      <filename>MIT-LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,2 @@
-- review the @custom_model_name stuff -- does this make any sense? does it belong on ControllerContext?
 - integrate association columns with acts_as_dropdown if present?
 </diff>
      <filename>TODO</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 /*  Streamlined.js
- *  (c) 2005-7 Relevance, LLC. (http://thinkrelevance.com)
+ *  (c) 2005-2008 Relevance, Inc.. (http://thinkrelevance.com)
  *
  *  Streamlined.js is freely distributable under the terms of an MIT-style license.
  *  For details, see http://streamlinedframework.org/</diff>
      <filename>files/public/javascripts/streamlined.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 # Streamlined
-# (c) 2005-7 Relevance, LLC. (http://thinkrelevance.com)
+# (c) 2005-2008 Relevance, Inc.. (http://thinkrelevance.com)
 # Streamlined is freely distributable under the terms of an MIT-style license.
 # For details, see http://streamlinedframework.org/
 #</diff>
      <filename>lib/relevance/active_record_extensions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,33 +1,50 @@
 # per controller context, kept for the lifetime of the controller class
 # and made available via delegation to controllers and views
 class Streamlined::Context::ControllerContext
-  attr_accessor :model_name
-  
-  DELEGATES = [:model_name,
-               :model, 
-               :model_symbol, 
-               :model_table, 
-               :model_underscore, 
-               :model_ui, 
-               {:to=&gt;:streamlined_controller_context}].freeze
-  
+  attr_accessor :ui_model_name, :ui_context
+             
+  def initialize(ui_model_name)
+    streamlined_ui(ui_model_name)
+  end
+                        
+  def self.delegates
+    [:model_name,
+     :model, 
+     :model_symbol, 
+     :model_table, 
+     :model_underscore, 
+     :model_ui,  
+     :streamlined_ui]
+  end
+              
   def model
-    @model ||= Class.class_eval(model_name)
+    Class.class_eval(model_name)
   end
   
   def model_symbol
-    @model_symbol ||= Inflector.underscore(model_name).to_sym
+    Inflector.underscore(model_name).to_sym
   end
   
   def model_table
-    @model_table ||= Inflector.tableize(model_name)
+    Inflector.tableize(model_name)
   end
   
   def model_underscore
-    @model_underscore ||= Inflector.underscore(model_name)
+    Inflector.underscore(model_name)
   end
     
   def model_ui
-    Streamlined.ui_for(model_name)
+    Streamlined.ui_for(ui_model_name, :context =&gt; ui_context)
+  end  
+
+  def model_name
+    ui_model_name
   end
+  
+  def streamlined_ui(ui_model_name, ui_context = nil, &amp;blk)
+    @ui_model_name = ui_model_name.to_s
+    @ui_context = ui_context
+    model_ui.instance_eval(&amp;blk) if block_given?
+  end
+  
 end
\ No newline at end of file</diff>
      <filename>lib/streamlined/context/controller_context.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 # Streamlined
-# (c) 2005-7 Relevance, LLC. (http://thinkrelevance.com)
+# (c) 2005-2008 Relevance, Inc.. (http://thinkrelevance.com)
 # Streamlined is freely distributable under the terms of an MIT-style license.
 # For details, see http://streamlinedframework.org/
 module Streamlined::Controller; end
@@ -47,26 +47,10 @@ module Streamlined::Controller::InstanceMethods
   
        
   private
-  def initialize_with_streamlined_variables
-    initialize_streamlined_values
-    streamlined_logger.info(&quot;model NAME: #{model_name}&quot;)
-    streamlined_logger.info(&quot;model: #{model.inspect}&quot;)
-  end
-  
   def initialize_request_context
     @streamlined_request_context = Streamlined::Context::RequestContext.new(params[:page_options])
   end
       
-  def initialize_streamlined_values
-    @streamlined_controller_context = Streamlined::Context::ControllerContext.new
-    @streamlined_controller_context.model_name = self.class.model_name || Inflector.classify(self.class.controller_name)
-    # TODO: why isn't this in the html head?
-    @page_title = &quot;Manage #{model_name.pluralize}&quot;
-  rescue Exception =&gt; ex
-    streamlined_logger.info(&quot;Could not instantiate controller: #{self.class.name}&quot;)
-    raise ex
-  end
-
   # rewrite of rails method
   def paginator_and_collection_for(collection_id, options) #:nodoc:
     klass = model
@@ -87,21 +71,13 @@ module Streamlined::Controller::InstanceMethods
 end
 
 module Streamlined::Controller::ClassMethods  
-  @custom_model_name = nil
-
   def acts_as_streamlined(options = {})
-    raise ArgumentError, &quot;options[:helpers] is deprecated&quot; if options[:helpers]
     class_eval do
-      attr_reader :streamlined_controller_context, :streamlined_request_context
+      attr_reader :streamlined_request_context
       attr_with_default(:breadcrumb_trail) {[]}
       helper_method :crud_context, :render_tabs, :render_partials, :instance, :breadcrumb_trail
-      # delegated helpers do not appear as routable actions!
-      def self.delegate_non_routable(*delegates_args)
-        delegates *delegates_args
-        delegates_args.each {|arg| hide_action(arg)}
-      end
-      delegate_non_routable(*Streamlined::Context::ControllerContext::DELEGATES)
-      delegate_non_routable(*Streamlined::Context::RequestContext::DELEGATES)
+      delegate_non_routable(*Streamlined::Context::RequestContext::DELEGATES) 
+      initialize_streamlined_controller_context(controller_name.singularize.classify)
       include Streamlined::Controller::InstanceMethods
       before_filter :initialize_request_context
       Dir[&quot;#{RAILS_ROOT}/app/streamlined/*.rb&quot;].each do |name|
@@ -110,18 +86,26 @@ module Streamlined::Controller::ClassMethods
       # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
       verify :method =&gt; :post, :only =&gt; [ :destroy, :create, :update ],
             :redirect_to =&gt; { :action =&gt; :list }
-      alias_method_chain :initialize, :streamlined_variables
     end
   end
-  
-  def model_name
-    @custom_model_name || nil
+
+  def delegate_non_routable(*delegates_args)
+    delegates *delegates_args
+    delegates_args.each {|arg| hide_action(arg)}
   end
   
-  def streamlined_model(mod)
-    @custom_model_name = mod.instance_of?(String) ? mod : mod.name
+  # controller name is passed in by acts_as_streamlined and becomes model name      
+  def initialize_streamlined_controller_context(model_name)        
+    class &lt;&lt; self
+      attr_reader :streamlined_controller_context 
+      delegate *Streamlined::Context::ControllerContext.delegates + 
+               [{:to =&gt; :streamlined_controller_context}]
+    end
+    @streamlined_controller_context = Streamlined::Context::ControllerContext.new(model_name)
+    delegate_non_routable *Streamlined::Context::ControllerContext.delegates + 
+                           [{:to =&gt; &quot;self.class&quot;}]
   end
-  
+
   def filters
     @filters ||= {}
   end</diff>
      <filename>lib/streamlined/controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 # Streamlined
-# (c) 2005-7 Relevance, LLC. (http://thinkrelevance.com)
+# (c) 2005-2008 Relevance, Inc.. (http://thinkrelevance.com)
 # Streamlined is freely distributable under the terms of an MIT-style license.
 # For details, see http://streamlinedframework.org/
 #
@@ -27,9 +27,14 @@ module Streamlined::Helper
   
   def self.included(includer)
     includer.class_eval do
-      attr_reader :streamlined_controller_context, :streamlined_request_context
-      # TODO: should delegate to controller, not controller context. Need to test. --SDH
-      delegates *Streamlined::Context::ControllerContext::DELEGATES
+      attr_reader :streamlined_request_context
+      delegates :model_name,
+                :model, 
+                :model_symbol, 
+                :model_table, 
+                :model_underscore, 
+                :model_ui,  
+                {:to=&gt;:controller}
       delegates :list_columns, :to=&gt;:model_ui
     end
   end</diff>
      <filename>lib/streamlined/helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 # Streamlined
-# (c) 2005-7 Relevance, LLC. (http://thinkrelevance.com)
+# (c) 2005-2008 Relevance, Inc.. (http://thinkrelevance.com)
 # Streamlined is freely distributable under the terms of an MIT-style license.
 # For details, see http://streamlinedframework.org/
 </diff>
      <filename>lib/streamlined/ui.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,6 @@ describe &quot;StreamlinedController&quot; do
   it &quot;delegated methods are not routable&quot; do
     action_methods = PeopleController.action_methods.map(&amp;:to_sym)
     (action_methods &amp; Streamlined::Context::RequestContext::DELEGATES).size.should == 0
-    (action_methods &amp; Streamlined::Context::ControllerContext::DELEGATES).size.should == 0
   end
   
   it &quot;should render index&quot; do</diff>
      <filename>test/functional/streamlined_controller_functional_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,18 +4,20 @@ require 'streamlined/ui'
 describe &quot;Streamlined::Context::ControllerContext&quot; do
   
   def setup
-    @context = Streamlined::Context::ControllerContext.new
-    @context.model_name = &quot;String&quot;
+    @context = Streamlined::Context::ControllerContext.new(String)
   end
   
   it &quot;model ui&quot; do
     assert_instance_of Streamlined::UI, @context.model_ui
-    context2 = Streamlined::Context::ControllerContext.new
-    context2.model_name = &quot;Integer&quot;
+    context2 = Streamlined::Context::ControllerContext.new(&quot;Integer&quot;)
     assert_not_equal context2.model_ui, @context.model_ui, &quot;every model class gets its own anonymous subclass for ui&quot;
   end
   
   it &quot;model ui uses passed model class&quot; do
     assert_equal String, @context.model_ui.model
+  end  
+  
+  it &quot;stringifies model class passed in, so callers can pass class or string&quot; do
+    assert_equal &quot;String&quot;, @context.ui_model_name
   end
 end
\ No newline at end of file</diff>
      <filename>test/unit/streamlined/context/controller_context_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,36 +8,24 @@ end
 describe &quot;Streamlined::Controller&quot; do
   include Streamlined::Controller::ClassMethods
   
-  # verify that exception is logged and rethrown
-  it &quot;initialize with streamlined variables&quot; do
-    o = Object.new
-    o.extend Streamlined::Controller::InstanceMethods
-    logger = flexmock(&quot;logger&quot;) do |mock|
-      mock.should_receive(:info).once
-    end 
-    flexmock(o, :streamlined_logger =&gt; logger)
-    flexmock(Streamlined::Context::ControllerContext).should_receive(:new).and_raise(RuntimeError,&quot;mocked!&quot;)
-    assert_raise(RuntimeError) do
-      o.send :initialize_streamlined_values
-    end
+  before do
+    @clazz = Class.new
+    @clazz.extend Streamlined::Controller::ClassMethods 
   end
   
-  it &quot;deprecation of helper overrides&quot; do
-    c = FooController
-    c.acts_as_streamlined
-    assert_nil c.send(:instance_variable_get, :@helper_overrides)
-    assert_raises(ArgumentError) do
-      c.acts_as_streamlined :helpers =&gt; [&quot;NEW HELPER&quot;]
-    end
+  it &quot;initialize streamlined controller context&quot; do
+    @clazz.expects(:delegate_non_routable)
+    @clazz.initialize_streamlined_controller_context(&quot;Foo&quot;)
+    context = @clazz.streamlined_controller_context
+    context.should.be.instance_of Streamlined::Context::ControllerContext
   end
   
   it &quot;streamlined model&quot; do
-    streamlined_model(&quot;Test&quot;)
-    assert_equal &quot;Test&quot;, model_name
-    streamlined_model(stub(:name =&gt; &quot;Tim&quot;))
-    assert_equal &quot;Tim&quot;, 
-                 model_name, 
-                 &quot;streamlined_model should extract name property&quot; 
+    @clazz.expects(:delegate_non_routable)
+    @clazz.initialize_streamlined_controller_context(&quot;Foo&quot;)
+    @clazz.model_name.should == &quot;Foo&quot;
+    @clazz.streamlined_ui(&quot;Bar&quot;)
+    @clazz.model_name.should == &quot;Bar&quot;
   end  
   
   it &quot;render filter&quot; do</diff>
      <filename>test/unit/streamlined/controller/controller_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c2cad41bd6e32e22d07101dac2bfec951c87f9b6</id>
    </parent>
  </parents>
  <author>
    <name>stu</name>
    <email>stu@4f249914-c612-0410-8deb-f4485a9d85ab</email>
  </author>
  <url>http://github.com/relevance/streamlined/commit/19b8b8d5893e796064d2777b91223b7cf4a84ae3</url>
  <id>19b8b8d5893e796064d2777b91223b7cf4a84ae3</id>
  <committed-date>2008-02-25T21:23:37-08:00</committed-date>
  <authored-date>2008-02-25T21:23:37-08:00</authored-date>
  <message>refactoring
* public API change! renamed streamlined_model to streamlined_ui
* reorganized controller context scope (created only once per controller)
* streamlined_ui can take a context, so different controllers can have different streamlined settings for the same model</message>
  <tree>907da1b45bc552518cf8598bebd662b26ee3226e</tree>
  <committer>
    <name>stu</name>
    <email>stu@4f249914-c612-0410-8deb-f4485a9d85ab</email>
  </committer>
</commit>
