Changeset 194
- Timestamp:
- 12/16/04 17:45:37 (4 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/base.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/cookies.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/dependencies.rb (modified) (5 diffs)
- trunk/actionpack/lib/action_controller/helpers.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/rescue.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/test_process.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/base.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/active_record_helper.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/form_helper.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/tag_helper.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/helpers/url_helper.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/base.rb
r142 r194 59 59 # 60 60 # def hello_ip 61 # location = @request.env["REMOTE_ ADDRESS"]61 # location = @request.env["REMOTE_IP"] 62 62 # render_text "Hello stranger from #{location}" 63 63 # end trunk/actionpack/lib/action_controller/cookies.rb
r117 r194 11 11 # cookies["user_name"] # => "david" 12 12 # cookies.size # => 2 13 # 14 # Example for deleting: 15 # 16 # cookies.delete "user_name" 13 17 # 14 18 # All the option symbols for setting cookies are: 15 19 # 16 # value::the cookie's value or list of values (as an array).17 # path::the path for which this cookie applies. Defaults to the root of the application.18 # domain::the domain for which this cookie applies.19 # expires::the time at which this cookie expires, as a +Time+ object.20 # secure::whether this cookie is a secure cookie or not (default to false).21 # Secure cookies are only transmitted to HTTPS servers.20 # * <tt>value</tt> - the cookie's value or list of values (as an array). 21 # * <tt>path</tt> - the path for which this cookie applies. Defaults to the root of the application. 22 # * <tt>domain</tt> - the domain for which this cookie applies. 23 # * <tt>expires</tt> - the time at which this cookie expires, as a +Time+ object. 24 # * <tt>secure</tt> - whether this cookie is a secure cookie or not (default to false). 25 # Secure cookies are only transmitted to HTTPS servers. 22 26 module Cookies 23 27 # Returns the cookie container, which operates as described above. trunk/actionpack/lib/action_controller/dependencies.rb
r175 r194 21 21 end 22 22 23 # Dependencies control what classes are needed for the controller to run its course. This is an alternative to doing explicit 24 # +require+ statements that bring a number of benefits. It's more succinct, communicates what type of dependency we're talking about, 25 # can trigger special behavior (as in the case of +observer+), and enables Rails to be clever about reloading in cached environments 26 # like FCGI. Example: 27 # 28 # class ApplicationController < ActionController::Base 29 # model :account, :company, :person, :project, :category 30 # helper :access_control 31 # service :notifications, :billings 32 # observer :project_change_observer 33 # end 34 # 35 # Please note that a controller like ApplicationController will automatically attempt to require_dependency on a model of its name and a helper 36 # of its name. If nothing is found, no error is raised. This is especially useful for concrete controllers like PostController: 37 # 38 # class PostController < ApplicationController 39 # # model :post (already required) 40 # # helper :post (already required) 41 # end 23 42 module ClassMethods 24 43 # Loads the <tt>file_name</tt> if reload_dependencies is true or requires if it's false. … … 27 46 end 28 47 48 # Specifies a variable number of models that this controller depends on. Models are normally Active Record classes or a similar 49 # backend for modelling entity classes. 29 50 def model(*models) 30 51 require_dependencies(:model, models) … … 32 53 end 33 54 55 # Specifies a variable number of services that this controller depends on. Services are normally singletons or factories, like 56 # Action Mailer service or a Payment Gateway service. 34 57 def service(*services) 35 58 require_dependencies(:service, services) … … 37 60 end 38 61 62 # Specifies a variable number of observers that are to govern when this controller is handling actions. The observers will 63 # automatically have .instance called on them to make them active on assignment. 39 64 def observer(*observers) 40 65 require_dependencies(:observer, observers) … … 43 68 end 44 69 45 def dependencies_on(layer) # :nodoc: 70 # Returns an array of symbols that specify the dependencies on a given layer. For the example at the top, calling 71 # <tt>ApplicationController.dependencies_on(:model)</tt> would return <tt>[:account, :company, :person, :project, :category]</tt> 72 def dependencies_on(layer) 46 73 read_inheritable_attribute("#{layer}_dependencies") 47 74 end 48 75 49 def depend_on(layer, dependencies) 76 def depend_on(layer, dependencies) #:nodoc: 50 77 write_inheritable_array("#{layer}_dependencies", dependencies) 51 78 end trunk/actionpack/lib/action_controller/helpers.rb
r32 r194 32 32 # See ActionView::Helpers (link:classes/ActionView/Helpers.html) for more about making your own helper modules 33 33 # available to the templates. 34 def add_template_helper(helper_module) 34 def add_template_helper(helper_module) #:nodoc: 35 35 template_class.class_eval "include #{helper_module}" 36 36 end trunk/actionpack/lib/action_controller/rescue.rb
r103 r194 16 16 end 17 17 18 module ClassMethods 18 module ClassMethods #:nodoc: 19 19 def process_with_exception(request, response, exception) 20 20 new.process(request, response, :rescue_action, exception) trunk/actionpack/lib/action_controller/test_process.rb
r80 r194 188 188 end 189 189 190 class Test::Unit::TestCase #:nodoc: 191 private 192 # execute the request and set/volley the response 193 def process(action, parameters = nil, session = nil) 194 @request.env['REQUEST_METHOD'] ||= "GET" 195 @request.action = action.to_s 196 @request.parameters.update(parameters) unless parameters.nil? 197 @request.session = ActionController::TestSession.new(session) unless session.nil? 198 @controller.process(@request, @response) 199 end 200 201 # execute the request simulating a specific http method and set/volley the response 202 %w( get post put delete head ).each do |method| 203 class_eval <<-EOV 204 def #{method}(action, parameters = nil, session = nil) 205 @request.env['REQUEST_METHOD'] = "#{method.upcase}" 206 process(action, parameters, session) 190 module Test 191 module Unit 192 class TestCase #:nodoc: 193 private 194 # execute the request and set/volley the response 195 def process(action, parameters = nil, session = nil) 196 @request.env['REQUEST_METHOD'] ||= "GET" 197 @request.action = action.to_s 198 @request.parameters.update(parameters) unless parameters.nil? 199 @request.session = ActionController::TestSession.new(session) unless session.nil? 200 @controller.process(@request, @response) 207 201 end 208 EOV 209 end 210 202 203 # execute the request simulating a specific http method and set/volley the response 204 %w( get post put delete head ).each do |method| 205 class_eval <<-EOV 206 def #{method}(action, parameters = nil, session = nil) 207 @request.env['REQUEST_METHOD'] = "#{method.upcase}" 208 process(action, parameters, session) 209 end 210 EOV 211 end 212 end 213 end 211 214 end trunk/actionpack/lib/action_view.rb
r4 r194 29 29 $:.unshift(File.dirname(__FILE__) + "/action_view/vendor") 30 30 require 'action_view/vendor/builder' 31 ensure32 # Temporary patch until it's in Builder 1.2.233 class BlankSlate34 class << self35 def hide(name)36 undef_method name if instance_methods.include?(name) and name !~ /^(__|instance_eval)/37 end38 end39 end40 31 end 41 32 trunk/actionpack/lib/action_view/base.rb
r121 r194 142 142 end 143 143 144 def self.controller_delegate(*methods) 144 def self.controller_delegate(*methods)#:nodoc: 145 145 methods.flatten.each do |method| 146 146 class_eval <<-end_eval trunk/actionpack/lib/action_view/helpers/active_record_helper.rb
r123 r194 84 84 # of <tt>object_name</tt>. This div can be tailored by the following options: 85 85 # 86 # ::header_tag:Used for the header of the error div (default: h2)87 # ::id:The id of the error div (default: errorExplanation)88 # ::class:The class of the error div (default: errorExplanation)86 # * <tt>header_tag</tt> - Used for the header of the error div (default: h2) 87 # * <tt>id</tt> - The id of the error div (default: errorExplanation) 88 # * <tt>class</tt> - The class of the error div (default: errorExplanation) 89 89 def error_messages_for(object_name, options={}) 90 90 object = instance_eval "@#{object_name}" trunk/actionpack/lib/action_view/helpers/form_helper.rb
r151 r194 92 92 # Example (call, result). Imagine that @post.validated? returns 1: 93 93 # check_box("post", "validated") 94 # <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /><input name="post[validated]" type="hidden" value="0" /> 94 # <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /> 95 # <input name="post[validated]" type="hidden" value="0" /> 95 96 # 96 97 # Example (call, result). Imagine that @puppy.gooddog returns no: 97 98 # check_box("puppy", "gooddog", {}, "yes", "no") 98 # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /><input name="puppy[gooddog]" type="hidden" value="no" /> 99 # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /> 100 # <input name="puppy[gooddog]" type="hidden" value="no" /> 99 101 def check_box(object, method, options = {}, checked_value = "1", unchecked_value = "0") 100 102 InstanceTag.new(object, method, self).to_check_box_tag(options, checked_value, unchecked_value) trunk/actionpack/lib/action_view/helpers/tag_helper.rb
r114 r194 8 8 9 9 # Examples: 10 # * tag("br") => <br />11 # * tag("input", { "type" => "text"}) => <input type="text" />10 # * <tt>tag("br") => <br /></tt> 11 # * <tt>tag("input", { "type" => "text"}) => <input type="text" /></tt> 12 12 def tag(name, options = {}, open = false) 13 13 "<#{name}#{tag_options(options)}" + (open ? ">" : " />") … … 15 15 16 16 # Examples: 17 # * content_tag("p", "Hello world!") => <p>Hello world!</p>18 # * content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") =>19 # < div class="strong"><p>Hello world!</p></div>17 # * <tt>content_tag("p", "Hello world!") => <p>Hello world!</p></tt> 18 # * <tt>content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") => </tt> 19 # <tt><div class="strong"><p>Hello world!</p></div></tt> 20 20 def content_tag(name, content, options = {}) 21 21 "<#{name}#{tag_options(options)}>#{content}</#{name}>" trunk/actionpack/lib/action_view/helpers/url_helper.rb
r106 r194 31 31 # letting the following special values enter the options on the image and the rest goes to the ahref: 32 32 # 33 # ::alt:If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension)34 # ::size:Supplied as "XxY", so "30x45" becomes width="30" and height="45"35 # ::border:Is set to 0 by default36 # ::align:Sets the alignment, no special features33 # * <tt>alt</tt> - If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension) 34 # * <tt>size</tt> - Supplied as "XxY", so "30x45" becomes width="30" and height="45" 35 # * <tt>border</tt> - Is set to 0 by default 36 # * <tt>align</tt> - Sets the alignment, no special features 37 37 # 38 38 # The +src+ can be supplied as a...