Commit Graph

85 Commits

Author SHA1 Message Date
Aaron Patterson
d47438745e remove RackDelegation module
Since all controller instances are required to have a request and
response object, RackDelegation is no longer needed (we always have to
delegate to the response)
2015-08-26 11:53:15 -07:00
Aaron Patterson
3cc35bed7a include ActionView::Rendering in the minimal controller
without this module, the content type is not set correctly
2015-08-26 11:53:15 -07:00
Aaron Patterson
54becd1a53 headers should delegate to the response object 2015-08-26 10:51:14 -07:00
Aaron Patterson
27daea82d7 use the content_type method on the request object
since the controller always has a request on it, we can just ask the
request for the content type.
2015-08-26 10:51:13 -07:00
Aaron Patterson
02f5a28f40 ask the response for the status
The controller instance always has an instance of a response object.  We
should store the status code on the response object so that it's only
store in one place.
2015-08-26 10:51:13 -07:00
Aaron Patterson
109fb8e7a9 remove useless conditional
We always have a response object in controller instances, so we can
remove this conditional
2015-08-26 10:51:13 -07:00
Aaron Patterson
44454bdd8b remove useless conditional
controller instances always have a response object, so we don't need to
test to see if there is one, just always call to_a on the response.
2015-08-26 10:51:13 -07:00
Aaron Patterson
51c7ac142d provide a request and response to all controllers
Controllers should always have a request and response when responding.
Since we make this The Rule(tm), then controllers don't need to be
somewhere in limbo between "asking a response object for a rack
response" or "I, myself contain a rack response".  This duality leads to
conditionals spread through the codebase that we can delete:

  * 85a78d9358/actionpack/lib/action_controller/metal.rb (L221-L223)
2015-08-25 18:35:44 -07:00
Aaron Patterson
67b2841fbe adding a direct dispatch method to controller classes
This saves a lambda and request allocation on each request.
2015-08-25 16:25:52 -07:00
Aaron Patterson
a26033b4a6 always dispatch to controllers the same way
controllers should always go through the `action` class method so that
their middleware is respected.
2015-08-25 16:00:20 -07:00
Aaron Patterson
05934d24af deprecate the env method on controller instances
people should be accessing request information through the request
object, not via the env hash.  If they really really want at the env
hash, then they can get it off the request.
2015-08-07 16:27:32 -07:00
Aaron Patterson
869b007172 the request object manages env
remove the setter.  The request object manages the env hash, so any
mutations need to go through it
2015-08-07 16:20:38 -07:00
Aaron Patterson
81cfdf2489 stop using @_env in the controller instance
Actions are processed through `dispatch`, so they should have the
request set on them before any user land code can be executed.  Lets
stop setting _env on the controller, and give access to it through the
`env` method.
2015-08-07 16:00:57 -07:00
Aaron Patterson
83b767cef9 Using strings or symbols for middleware class names is deprecated.
Convert things like this:

  middleware.use "Foo::Bar"

to this:

  middleware.use Foo::Bar
2015-08-07 15:37:31 -07:00
Aaron Patterson
435b224e7e move valid? conditional to the constructor
use a strategy pattern to calculate the conditional in `valid?` in
advance.
2015-08-07 15:37:31 -07:00
Aaron Patterson
27eddbb332 simplify the Middleware constructor
We should do the hard work outside the constructor.  Also fix the tests
to not directly construct middleware objects, but to go through the
stack object.
2015-08-07 15:37:31 -07:00
Aaron Patterson
4485351501 the request class is never changed, so just use it directly in the method body 2015-08-07 15:37:31 -07:00
brainopia
ee6e13f3da Add ActionController::Metal#set_request!
Add `ActionController::Metal#set_request!` to set a request
on controller instance without calling dispatch.
2015-01-21 23:53:38 +03:00
Robin Dupret
7ef7f1cc15 Correctly use the response's status code calling head
Commit 20fece1 introduced the `_status_code` method to fix calls to
`head :ok`. This method has been added on both ActionController::Metal
and ActionDispatch::Response.

As for the latter, this method is just equivalent to the `response_code`
one so commit aefec3c removed it from the `Reponse` object so call to
the `_status_code` method on an ActionController::Base instance would be
handled by the `Metal` class (which `Base` inherits from) but the status
code is not updated according to the response at this level.

The fix is to actually rely on `response_code` for ActionController::Base
instances but this method doesn't exist for bare Metal controllers so we
need to define it.
2014-12-31 16:37:35 +01:00
Prathamesh Sonpatki
295621e436 Make _status_code methods nodoc
- Also one minor change for documenting url_for method in ActionController::Metal.
[ci skip]
2014-10-19 22:12:59 +05:30
Vijay Dev
d9bd75a0d8 copy edits[ci skip] 2014-08-02 12:05:26 +00:00
Gaurish Sharma
78788ad723 Performed Returns true if redirect/render has happened 2014-07-19 20:06:59 +05:30
Aaron Patterson
cfdab77d1f Merge branch 'constraints'
* constraints:
  rm reset_parameters because we automatically do it from 9ca4839a
  move path_parameter encoding check to the request object
  dispatcher doesn't need `call` anymore
  call `serve` with the request on dispatchers
  constraints class does not need the request class anymore
  give all endpoints a superclass
  skip the build business if the stack is empty
  stop hardcoding path_parameters and get it from the request
  we do not need to cache rack_app
  a redirect is not a dispatcher by definition, so eliminate test
  push is_a check up to where the Constraints object is allocated
  pass the request object to the application
  pass a request to `matches?` so we can avoid creating excess requests
  nothing is passed to `rack_app` anymore, so rm the params
  one fewer is_a check
  Constraints#app should never return another Constraints object, so switch to if statement
  eliminate dispatcher is_a checks
  push is_a?(Dispatcher) check in to one place
  Always construct route objects with Constraint objects

Conflicts:
	actionpack/lib/action_controller/metal.rb
2014-05-27 14:40:55 -07:00
Aaron Patterson
40514aa23a skip the build business if the stack is empty 2014-05-26 17:30:17 -07:00
Aaron Patterson
02a9401d78 stop hardcoding path_parameters and get it from the request 2014-05-26 17:19:54 -07:00
Guo Xiang Tan
86396f8c30 Remove duplicated to_s method call. 2014-05-25 19:07:57 -07:00
Aaron Patterson
93ae747c59 use Proc.new to automatically do parameter checking for us 2014-05-23 11:21:26 -07:00
Christiaan Van den Poel
20fece1491 fixes stack level too deep exception on action named 'status' returning 'head :ok' 2014-05-15 21:14:46 +02:00
Yury Velikanau
5f11d13f2a Update AC::Metal documentation example [ci skip]
Include proper module since AV was extracted form AP as mentioned in #14659.
2014-04-15 13:57:42 -07:00
buddhamagnet
2948668bf1 Increase readability of ternary statement in build method 2013-04-20 15:24:23 +01:00
Gaurish Sharma
bb74b3952e replace match with get verb in ActionController::Metal 2013-04-16 09:45:45 +05:30
Akira Matsuda
9c1cd6b142 Missing or unneeded require extract_options 2013-02-01 12:10:58 +09:00
AvnerCohen
62f273b650 Multiple changes to 1,9 hash syntax 2012-10-27 22:05:27 +02:00
Xavier Noria
3c48b32f6e removes unnecessary self 2012-09-17 17:32:19 +02:00
Xavier Noria
18dbad80ab revises RDoc in AC::Metal [ci skip] 2012-09-17 17:32:19 +02:00
Xavier Noria
4363368e85 removes unnecessary self 2012-09-17 17:32:18 +02:00
Xavier Noria
5e1b92044c load active_support/core_ext/class/attribute in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
8f58d6e507 load active_support/core_ext/object/blank in active_support/rails 2012-08-02 21:59:22 +02:00
Aaron Patterson
356787fce8 adding a buffered stream to the response object 2012-07-29 15:51:21 -07:00
Carlos Antonio da Silva
1b4edd173d Use performed? instead of checking for response_body
* Check for performed? instead of response_body
* Change performed? to return a boolean
* Refactor AC::Metal#response_body= to reuse variable
2012-01-19 18:25:52 -02:00
José Valim
e2cc653876 Do not deprecate performed. 2012-01-19 19:52:10 +01:00
Vasiliy Ermolovich
6f3420c037 refactor response_body= method
response_to?(:each) returns false for strings in ruby 1.9, so there is no need for these checks
2012-01-14 14:33:52 +03:00
Akira Matsuda
cc3e738d89 Fix AC::Metal#response_body= to store same value on Ruby 1.8 and 1.9
This was because String#respond_to?(:each) differs in 1.8 and 1.9
2011-11-07 16:24:54 +09:00
Aaron Patterson
3dc4d543f1 make our constructor signature match the superclass 2011-04-17 11:49:25 -07:00
Gabriel Horner
cc446d6c9f Add docs for ActionController::Metal class methods 2011-03-28 23:48:45 -04:00
Jon Leighton
735844db71 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
	activerecord/lib/active_record/associations/has_one_through_association.rb
	activerecord/lib/active_record/associations/through_association_scope.rb
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/associations/has_many_through_associations_test.rb
	activerecord/test/cases/associations/has_one_through_associations_test.rb
	activerecord/test/cases/reflection_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/fixtures/memberships.yml
	activerecord/test/models/categorization.rb
	activerecord/test/models/category.rb
	activerecord/test/models/member.rb
	activerecord/test/models/reference.rb
	activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Xavier Noria
e99e859a04 revises a metal example 2011-02-02 23:27:27 +01:00
Xavier Noria
33643bcf53 copy-edits 2446b13 2011-02-02 23:04:12 +01:00
Xavier Noria
a96a9a4948 Merge branch 'master' of git://github.com/lifo/docrails 2011-02-02 22:04:11 +01:00
Bernerd Schaefer
2446b1307e Provide documentation for ActionController::Metal 2011-02-02 16:02:28 +01:00