exposure 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
 - data/lib/exposure/behaviors/building.rb +4 -4
 - data/lib/exposure/behaviors/callbacks.rb +4 -4
 - data/lib/exposure/behaviors/finding.rb +9 -8
 - data/lib/exposure/behaviors/flashing.rb +2 -2
 - data/lib/exposure/behaviors/responding.rb +2 -2
 - data/lib/exposure/patterns/resources.rb +23 -23
 - data/lib/exposure.rb +1 -0
 - data/spec/builders/builder_spec.rb +1 -1
 - data/spec/finders/finder_spec.rb +35 -5
 - data/spec/flashers/flash_with_proc_spec.rb +1 -1
 - data/spec/responders/respond_with_proc_spec.rb +1 -1
 - metadata +2 -2
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.2.0
         
     | 
| 
         @@ -2,7 +2,7 @@ module Exposure 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Building
         
     | 
| 
       3 
3 
     | 
    
         
             
                def self.included(base)
         
     | 
| 
       4 
4 
     | 
    
         
             
                  base.extend ClassMethods
         
     | 
| 
       5 
     | 
    
         
            -
                  base.send(:include,  
     | 
| 
      
 5 
     | 
    
         
            +
                  base.send(:include, InstanceMethods)
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                module ClassMethods
         
     | 
| 
         @@ -20,17 +20,17 @@ module Exposure 
     | 
|
| 
       20 
20 
     | 
    
         
             
                  def build_default_builder(member, nesting)
         
     | 
| 
       21 
21 
     | 
    
         
             
                    if nesting.any?
         
     | 
| 
       22 
22 
     | 
    
         
             
                      builders = self::const_set(:DefaultBuilders, {
         
     | 
| 
       23 
     | 
    
         
            -
                        self.resource_name.intern  =>  
     | 
| 
      
 23 
     | 
    
         
            +
                        self.resource_name.intern  => proc { [:build, params[resource_name] ] },
         
     | 
| 
       24 
24 
     | 
    
         
             
                      })
         
     | 
| 
       25 
25 
     | 
    
         
             
                    else
         
     | 
| 
       26 
26 
     | 
    
         
             
                      self::const_set(:DefaultBuilders, {
         
     | 
| 
       27 
     | 
    
         
            -
                        self.resource_name.intern  =>  
     | 
| 
      
 27 
     | 
    
         
            +
                        self.resource_name.intern  => proc { [:new, params[resource_name] ] },
         
     | 
| 
       28 
28 
     | 
    
         
             
                      })
         
     | 
| 
       29 
29 
     | 
    
         
             
                    end
         
     | 
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                module  
     | 
| 
      
 33 
     | 
    
         
            +
                module InstanceMethods
         
     | 
| 
       34 
34 
     | 
    
         
             
                  private
         
     | 
| 
       35 
35 
     | 
    
         
             
                    def custom_builder_for(resource_name)
         
     | 
| 
       36 
36 
     | 
    
         
             
                      if builder = self.class::Builders[resource_name]
         
     | 
| 
         @@ -2,7 +2,7 @@ module Exposure 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Callbacks
         
     | 
| 
       3 
3 
     | 
    
         
             
                def self.included(base)
         
     | 
| 
       4 
4 
     | 
    
         
             
                  base.extend ClassMethods
         
     | 
| 
       5 
     | 
    
         
            -
                  base.send(:include,  
     | 
| 
      
 5 
     | 
    
         
            +
                  base.send(:include, InstanceMethods)
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                module ClassMethods
         
     | 
| 
         @@ -36,18 +36,18 @@ module Exposure 
     | 
|
| 
       36 
36 
     | 
    
         
             
                    except_methods = Array.wrap(options.delete(:except))
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                    if only_methods.any?
         
     | 
| 
       39 
     | 
    
         
            -
                      options[:if] <<  
     | 
| 
      
 39 
     | 
    
         
            +
                      options[:if] << proc {|c| only_methods.include?(c.action_name.intern) }
         
     | 
| 
       40 
40 
     | 
    
         
             
                    end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                    if except_methods.any?
         
     | 
| 
       43 
     | 
    
         
            -
                      options[:if] <<  
     | 
| 
      
 43 
     | 
    
         
            +
                      options[:if] << proc {|c| !except_methods.include?(c.action_name.intern) }
         
     | 
| 
       44 
44 
     | 
    
         
             
                    end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                    self.send(callback_name, action, options)
         
     | 
| 
       47 
47 
     | 
    
         
             
                  end
         
     | 
| 
       48 
48 
     | 
    
         
             
                end
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                module  
     | 
| 
      
 50 
     | 
    
         
            +
                module InstanceMethods
         
     | 
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
| 
       52 
52 
     | 
    
         
             
              end
         
     | 
| 
       53 
53 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,12 +2,12 @@ module Exposure 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Finding
         
     | 
| 
       3 
3 
     | 
    
         
             
                def self.included(base)
         
     | 
| 
       4 
4 
     | 
    
         
             
                  base.extend ClassMethods
         
     | 
| 
       5 
     | 
    
         
            -
                  base.send(:include,  
     | 
| 
      
 5 
     | 
    
         
            +
                  base.send(:include, InstanceMethods)
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                module ClassMethods
         
     | 
| 
       9 
     | 
    
         
            -
                  # find :person, :with =>  
     | 
| 
       10 
     | 
    
         
            -
                  # find :people, :with =>  
     | 
| 
      
 9 
     | 
    
         
            +
                  # find :person, :with => proc { Person.find_by_permalink(params[:permalink]) }
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # find :people, :with => proc { Person.send(params[:scope]) }
         
     | 
| 
       11 
11 
     | 
    
         
             
                  # find :dogs, :with => :dogs_adopted_after_date
         
     | 
| 
       12 
12 
     | 
    
         
             
                  # find :dogs do
         
     | 
| 
       13 
13 
     | 
    
         
             
                  #   Dog.all
         
     | 
| 
         @@ -49,18 +49,18 @@ module Exposure 
     | 
|
| 
       49 
49 
     | 
    
         | 
| 
       50 
50 
     | 
    
         
             
                  def build_default_finders(member, nesting) #:nodoc:
         
     | 
| 
       51 
51 
     | 
    
         
             
                    finders = self::const_set(:DefaultFinders, {
         
     | 
| 
       52 
     | 
    
         
            -
                      self.resource_name.intern  =>  
     | 
| 
       53 
     | 
    
         
            -
                      self.resources_name.intern =>  
     | 
| 
      
 52 
     | 
    
         
            +
                      self.resource_name.intern  => proc { [:find, params[:id] ] },
         
     | 
| 
      
 53 
     | 
    
         
            +
                      self.resources_name.intern => proc { [:all] }
         
     | 
| 
       54 
54 
     | 
    
         
             
                    })
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
56 
     | 
    
         
             
                    nesting.each do |association_name|
         
     | 
| 
       57 
     | 
    
         
            -
                      finders[association_name.to_s.singularize.to_sym] =  
     | 
| 
       58 
     | 
    
         
            -
                      finders[association_name] =  
     | 
| 
      
 57 
     | 
    
         
            +
                      finders[association_name.to_s.singularize.to_sym] = proc { [:find, params[:"#{association_name.to_s.singularize}_id"]] }
         
     | 
| 
      
 58 
     | 
    
         
            +
                      finders[association_name] = proc { [ :all ] }
         
     | 
| 
       59 
59 
     | 
    
         
             
                    end
         
     | 
| 
       60 
60 
     | 
    
         
             
                  end
         
     | 
| 
       61 
61 
     | 
    
         
             
                end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                module  
     | 
| 
      
 63 
     | 
    
         
            +
                module InstanceMethods
         
     | 
| 
       64 
64 
     | 
    
         
             
                  private
         
     | 
| 
       65 
65 
     | 
    
         
             
                    def custom_finder_for(resource_name)
         
     | 
| 
       66 
66 
     | 
    
         
             
                      if finder = self.class::Finders[resource_name]
         
     | 
| 
         @@ -99,6 +99,7 @@ module Exposure 
     | 
|
| 
       99 
99 
     | 
    
         
             
                        if use_associaiton
         
     | 
| 
       100 
100 
     | 
    
         
             
                          call_finder_chain(object.send(association).send(*value), chain)
         
     | 
| 
       101 
101 
     | 
    
         
             
                        else
         
     | 
| 
      
 102 
     | 
    
         
            +
                          return value if value.empty? || value[0].kind_of?(ActiveRecord::Base) # the find already executed
         
     | 
| 
       102 
103 
     | 
    
         
             
                          call_finder_chain(object.send(*value), chain)
         
     | 
| 
       103 
104 
     | 
    
         
             
                        end
         
     | 
| 
       104 
105 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -2,7 +2,7 @@ module Exposure 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Flashing
         
     | 
| 
       3 
3 
     | 
    
         
             
                def self.included(base)
         
     | 
| 
       4 
4 
     | 
    
         
             
                  base.extend ClassMethods
         
     | 
| 
       5 
     | 
    
         
            -
                  base.send(:include,  
     | 
| 
      
 5 
     | 
    
         
            +
                  base.send(:include, InstanceMethods)
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                module ClassMethods
         
     | 
| 
         @@ -30,7 +30,7 @@ module Exposure 
     | 
|
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                module  
     | 
| 
      
 33 
     | 
    
         
            +
                module InstanceMethods
         
     | 
| 
       34 
34 
     | 
    
         
             
                  private
         
     | 
| 
       35 
35 
     | 
    
         
             
                    def custom_flash_for(action_name, action_status)
         
     | 
| 
       36 
36 
     | 
    
         
             
                      if flash_message = self.class::FlashMessages["#{action_name}.#{action_status}.html"]
         
     | 
| 
         @@ -2,7 +2,7 @@ module Exposure 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Responding
         
     | 
| 
       3 
3 
     | 
    
         
             
                def self.included(base)
         
     | 
| 
       4 
4 
     | 
    
         
             
                  base.extend ClassMethods
         
     | 
| 
       5 
     | 
    
         
            -
                  base.send(:include,  
     | 
| 
      
 5 
     | 
    
         
            +
                  base.send(:include, InstanceMethods)
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                module ClassMethods
         
     | 
| 
         @@ -48,7 +48,7 @@ module Exposure 
     | 
|
| 
       48 
48 
     | 
    
         
             
                  end
         
     | 
| 
       49 
49 
     | 
    
         
             
                end
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                module  
     | 
| 
      
 51 
     | 
    
         
            +
                module InstanceMethods
         
     | 
| 
       52 
52 
     | 
    
         
             
                  private
         
     | 
| 
       53 
53 
     | 
    
         
             
                    def custom_response_for(action_name, action_status, format)
         
     | 
| 
       54 
54 
     | 
    
         
             
                      if responder = self.class::Responses["#{action_name}.#{action_status}.#{format}"]
         
     | 
| 
         @@ -24,35 +24,35 @@ module Exposure 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  )
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                  DefaultFlashMessages = {
         
     | 
| 
       27 
     | 
    
         
            -
                    'create.success.html' =>  
     | 
| 
       28 
     | 
    
         
            -
                    'update.success.html' =>  
     | 
| 
       29 
     | 
    
         
            -
                    'destroy.success.html' =>  
     | 
| 
      
 27 
     | 
    
         
            +
                    'create.success.html' => proc { "#{resource_name.capitalize} successfully created" },
         
     | 
| 
      
 28 
     | 
    
         
            +
                    'update.success.html' => proc { "#{resource_name.capitalize} successfully updated" },
         
     | 
| 
      
 29 
     | 
    
         
            +
                    'destroy.success.html' => proc { "#{resource_name.capitalize} successfully removed" }
         
     | 
| 
       30 
30 
     | 
    
         
             
                  }
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
                  DefaultResponses = {
         
     | 
| 
       33 
     | 
    
         
            -
                    'index.success.html'  =>  
     | 
| 
       34 
     | 
    
         
            -
                    'show.success.html'   =>  
     | 
| 
       35 
     | 
    
         
            -
                    'new.success.html'    =>  
     | 
| 
       36 
     | 
    
         
            -
                    'create.success.html' =>  
     | 
| 
       37 
     | 
    
         
            -
                    'edit.success.html'   =>  
     | 
| 
       38 
     | 
    
         
            -
                    'update.success.html' =>  
     | 
| 
       39 
     | 
    
         
            -
                    'destroy.success.html'=>  
     | 
| 
       40 
     | 
    
         
            -
                    'create.failure.html' =>  
     | 
| 
       41 
     | 
    
         
            -
                    'update.failure.html' =>  
     | 
| 
       42 
     | 
    
         
            -
                    'index.success.xml'   =>  
     | 
| 
       43 
     | 
    
         
            -
                    'show.success.xml'   =>  
     | 
| 
       44 
     | 
    
         
            -
                    'new.success.xml'    =>  
     | 
| 
       45 
     | 
    
         
            -
                    'create.success.xml' =>  
     | 
| 
       46 
     | 
    
         
            -
                    'created.failure.xml'=>  
     | 
| 
       47 
     | 
    
         
            -
                    'update.success.xml' =>  
     | 
| 
       48 
     | 
    
         
            -
                    'update.failure.xml' =>  
     | 
| 
       49 
     | 
    
         
            -
                    'destroy.success.xml'=>  
     | 
| 
      
 33 
     | 
    
         
            +
                    'index.success.html'  => proc   { render('index') },
         
     | 
| 
      
 34 
     | 
    
         
            +
                    'show.success.html'   => proc   { render('show')  },
         
     | 
| 
      
 35 
     | 
    
         
            +
                    'new.success.html'    => proc   { render('new')   },
         
     | 
| 
      
 36 
     | 
    
         
            +
                    'create.success.html' => proc  { redirect_to({:action => 'index'}) },
         
     | 
| 
      
 37 
     | 
    
         
            +
                    'edit.success.html'   => proc  { render('edit')  },
         
     | 
| 
      
 38 
     | 
    
         
            +
                    'update.success.html' => proc  { redirect_to({:action => 'show' }) },
         
     | 
| 
      
 39 
     | 
    
         
            +
                    'destroy.success.html'=> proc { redirect_to({:action => 'index'}) },
         
     | 
| 
      
 40 
     | 
    
         
            +
                    'create.failure.html' => proc { render('new')    },
         
     | 
| 
      
 41 
     | 
    
         
            +
                    'update.failure.html' => proc { render('edit')   },
         
     | 
| 
      
 42 
     | 
    
         
            +
                    'index.success.xml'   => proc { render(:xml => @resources) },
         
     | 
| 
      
 43 
     | 
    
         
            +
                    'show.success.xml'   => proc  { render(:xml => @resource) },
         
     | 
| 
      
 44 
     | 
    
         
            +
                    'new.success.xml'    => proc  { render(:xml => @resource) },
         
     | 
| 
      
 45 
     | 
    
         
            +
                    'create.success.xml' => proc  { render({:xml => @resource, :status => :created, :location => @resource}) },
         
     | 
| 
      
 46 
     | 
    
         
            +
                    'created.failure.xml'=> proc  { render(:xml => @resource.errors, :status => :unprocessable_entity)},
         
     | 
| 
      
 47 
     | 
    
         
            +
                    'update.success.xml' => proc  { head(:ok)},
         
     | 
| 
      
 48 
     | 
    
         
            +
                    'update.failure.xml' => proc  { render(:xml => @resource.errors, :status => :unprocessable_entity)},
         
     | 
| 
      
 49 
     | 
    
         
            +
                    'destroy.success.xml'=> proc  { head(:ok)}
         
     | 
| 
       50 
50 
     | 
    
         
             
                  }
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
52 
     | 
    
         
             
                  module Actions
         
     | 
| 
       53 
     | 
    
         
            -
                    def index
         
     | 
| 
      
 53 
     | 
    
         
            +
                    def index          
         
     | 
| 
       54 
54 
     | 
    
         
             
                      run_callbacks(:before_find_many)
         
     | 
| 
       55 
     | 
    
         
            -
                       if find_records
         
     | 
| 
      
 55 
     | 
    
         
            +
                       if find_records             
         
     | 
| 
       56 
56 
     | 
    
         
             
                         run_callbacks(:after_find_many_on_success)
         
     | 
| 
       57 
57 
     | 
    
         
             
                         run_callbacks(:after_find_many)
         
     | 
| 
       58 
58 
     | 
    
         
             
                         run_callbacks(:before_response)
         
     | 
| 
         @@ -216,7 +216,7 @@ module Exposure 
     | 
|
| 
       216 
216 
     | 
    
         
             
                        @resource = instance_variable_set("@#{resource_name}", call_finder_chain(parent_model, self.class.member_nesting, false))
         
     | 
| 
       217 
217 
     | 
    
         
             
                      end
         
     | 
| 
       218 
218 
     | 
    
         | 
| 
       219 
     | 
    
         
            -
                      def find_records 
     | 
| 
      
 219 
     | 
    
         
            +
                      def find_records        
         
     | 
| 
       220 
220 
     | 
    
         
             
                        @resources = instance_variable_set("@#{resources_name}", call_finder_chain(parent_model, self.class.collection_nesting, false))
         
     | 
| 
       221 
221 
     | 
    
         
             
                      end
         
     | 
| 
       222 
222 
     | 
    
         | 
    
        data/lib/exposure.rb
    CHANGED
    
    
| 
         @@ -34,7 +34,7 @@ describe "builders", :type => :controller do 
     | 
|
| 
       34 
34 
     | 
    
         
             
              end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
              it "builds with a proc" do
         
     | 
| 
       37 
     | 
    
         
            -
                PiratesController.build :pirate, :with =>  
     | 
| 
      
 37 
     | 
    
         
            +
                PiratesController.build :pirate, :with => proc { Pirate.new(params[:pirate]) }
         
     | 
| 
       38 
38 
     | 
    
         
             
                post(:create, {:pirate => {}}).inspect
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                should assign_to(:pirate).with(@pirate)
         
     | 
    
        data/spec/finders/finder_spec.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe "finders", :type => :controller do 
     | 
| 
      
 3 
     | 
    
         
            +
            describe "finders", :type => :controller do
         
     | 
| 
       4 
4 
     | 
    
         
             
              setup = lambda {
         
     | 
| 
       5 
5 
     | 
    
         
             
                class PiratesController < ActionController::Base
         
     | 
| 
       6 
6 
     | 
    
         
             
                  expose_many(:pirates)
         
     | 
| 
         @@ -8,6 +8,10 @@ describe "finders", :type => :controller do 
     | 
|
| 
       8 
8 
     | 
    
         
             
                    def find_pirate
         
     | 
| 
       9 
9 
     | 
    
         
             
                      Pirate.find_by_title(params[:id])
         
     | 
| 
       10 
10 
     | 
    
         
             
                    end
         
     | 
| 
      
 11 
     | 
    
         
            +
                    
         
     | 
| 
      
 12 
     | 
    
         
            +
                    def find_pirates
         
     | 
| 
      
 13 
     | 
    
         
            +
                      Pirate.all
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
       11 
15 
     | 
    
         
             
                end
         
     | 
| 
       12 
16 
     | 
    
         | 
| 
       13 
17 
     | 
    
         
             
                ActionController::Routing::Routes.draw do |map| 
         
     | 
| 
         @@ -26,28 +30,44 @@ describe "finders", :type => :controller do 
     | 
|
| 
       26 
30 
     | 
    
         
             
                @response   = ActionController::TestResponse.new
         
     | 
| 
       27 
31 
     | 
    
         | 
| 
       28 
32 
     | 
    
         
             
                @pirate = Factory.stub(:pirate)
         
     | 
| 
      
 33 
     | 
    
         
            +
                @pirates = [Factory.stub(:pirate)]
         
     | 
| 
       29 
34 
     | 
    
         
             
                Pirate.stub(:find_by_title => @pirate)
         
     | 
| 
      
 35 
     | 
    
         
            +
                Pirate.stub(:all => @pirates)
         
     | 
| 
       30 
36 
     | 
    
         
             
              end
         
     | 
| 
       31 
37 
     | 
    
         | 
| 
       32 
38 
     | 
    
         
             
              after(:each) do
         
     | 
| 
       33 
39 
     | 
    
         
             
                Object.remove_class(PiratesController)
         
     | 
| 
       34 
40 
     | 
    
         
             
              end
         
     | 
| 
       35 
41 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
              it "finds with a method name as symbol" do
         
     | 
| 
       37 
     | 
    
         
            -
                PiratesController.find :pirate, :with =>  
     | 
| 
      
 42 
     | 
    
         
            +
              it "finds member resource with a method name as symbol" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                PiratesController.find :pirate, :with => proc { Pirate.find_by_title(params[:id]) }
         
     | 
| 
       38 
44 
     | 
    
         
             
                get(:show, {:id => 'Captain'})
         
     | 
| 
       39 
45 
     | 
    
         | 
| 
       40 
46 
     | 
    
         
             
                should assign_to(:pirate).with(@pirate)
         
     | 
| 
       41 
47 
     | 
    
         
             
              end
         
     | 
| 
       42 
48 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
              it "finds with a  
     | 
| 
      
 49 
     | 
    
         
            +
              it "finds collection resource with a method name as symbol" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                PiratesController.find :pirates, :with => proc { [:all] }
         
     | 
| 
      
 51 
     | 
    
         
            +
                get(:index)
         
     | 
| 
      
 52 
     | 
    
         
            +
                
         
     | 
| 
      
 53 
     | 
    
         
            +
                should assign_to(:pirates).with(@pirates)
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
              
         
     | 
| 
      
 56 
     | 
    
         
            +
              it "finds member resource with a proc" do
         
     | 
| 
       44 
57 
     | 
    
         
             
                PiratesController.find :pirate, :with => :find_pirate
         
     | 
| 
       45 
58 
     | 
    
         
             
                get(:show, {:id => 'Captain'})
         
     | 
| 
       46 
59 
     | 
    
         | 
| 
       47 
60 
     | 
    
         
             
                should assign_to(:pirate).with(@pirate)    
         
     | 
| 
       48 
61 
     | 
    
         
             
              end
         
     | 
| 
       49 
62 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
              it "finds with a  
     | 
| 
      
 63 
     | 
    
         
            +
              it "finds collection resource with a proc" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                PiratesController.find :pirates, :with => :find_pirates
         
     | 
| 
      
 65 
     | 
    
         
            +
                get(:index)
         
     | 
| 
      
 66 
     | 
    
         
            +
                
         
     | 
| 
      
 67 
     | 
    
         
            +
                should assign_to(:pirates).with(@pirates)    
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
              
         
     | 
| 
      
 70 
     | 
    
         
            +
              it "finds member resource with a block" do
         
     | 
| 
       51 
71 
     | 
    
         
             
                PiratesController.find :pirate do
         
     | 
| 
       52 
72 
     | 
    
         
             
                  Pirate.find_by_title(params[:id])
         
     | 
| 
       53 
73 
     | 
    
         
             
                end
         
     | 
| 
         @@ -56,4 +76,14 @@ describe "finders", :type => :controller do 
     | 
|
| 
       56 
76 
     | 
    
         | 
| 
       57 
77 
     | 
    
         
             
                should assign_to(:pirate).with(@pirate)    
         
     | 
| 
       58 
78 
     | 
    
         
             
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
              
         
     | 
| 
      
 80 
     | 
    
         
            +
              it "finds collection resource with a block" do
         
     | 
| 
      
 81 
     | 
    
         
            +
                PiratesController.find :pirates do
         
     | 
| 
      
 82 
     | 
    
         
            +
                  [:all]
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
      
 84 
     | 
    
         
            +
                
         
     | 
| 
      
 85 
     | 
    
         
            +
                get(:index)
         
     | 
| 
      
 86 
     | 
    
         
            +
                
         
     | 
| 
      
 87 
     | 
    
         
            +
                should assign_to(:pirates).with(@pirates)    
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
       59 
89 
     | 
    
         
             
            end
         
     | 
| 
         @@ -10,7 +10,7 @@ describe "flash messages with procs", :type => :controller do 
     | 
|
| 
       10 
10 
     | 
    
         
             
              setup.call
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              def setup_flasher(action, success = nil)
         
     | 
| 
       13 
     | 
    
         
            -
                PiratesController.flash_for :create, :is =>  
     | 
| 
      
 13 
     | 
    
         
            +
                PiratesController.flash_for :create, :is => proc { 'the flash was set' }, :on => success
         
     | 
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              ActionController::Routing::Routes.draw do |map| 
         
     | 
| 
         @@ -14,7 +14,7 @@ describe "responders", :type => :controller do 
     | 
|
| 
       14 
14 
     | 
    
         
             
               end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
               def setup_responder(action, success = nil)
         
     | 
| 
       17 
     | 
    
         
            -
                 PiratesController.response_for :create, :is =>  
     | 
| 
      
 17 
     | 
    
         
            +
                 PiratesController.response_for :create, :is => proc { redirect_to({:action => "test"}) }, :on => success
         
     | 
| 
       18 
18 
     | 
    
         
             
               end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              controller_name :pirates
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: exposure
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Trek Glowacki
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2010-04-05 00:00:00 -04:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
15 
     | 
    
         |