Commit Graph

26350 Commits

Author SHA1 Message Date
José Valim
76a3ec7f6e Try to play nice with plugins doing monkey patches. 2011-12-02 09:57:43 +01:00
Jon Leighton
6bff6439b1 Fewer string allocations in attribute method 2011-12-01 23:41:51 +00:00
Jon Leighton
f6b5046305 Roflscaling!
Don't prefix the name with attribute_. Avoids a string allocation on
read_attribute, which is a bit faster.
2011-12-01 23:41:51 +00:00
Jon Leighton
9ead4130de Create method with known identifier then alias into place.
This means we never have to rely on define_method (which is slower and
uses more memory), even when we have attributes containing characters
that are not allowed in standard method names.

(I am mainly changing this because the duplication annoys me, though.)
2011-12-01 23:41:51 +00:00
Jon Leighton
bd920eae82 Remove some unnecessary code etc 2011-12-01 23:41:51 +00:00
Jon Leighton
e9fb6d04bd Add test for read_attribute(:id) with non-standard PK.
Also make it actually work.

It slows down all read_attribute accesses to map 'id' to whatever the PK
actually is, inside read_attribute. So instead make sure the necessary
methods are defined and that they redirect wherever they need to go.
2011-12-01 23:41:51 +00:00
Jon Leighton
f1a534af98 Remove the need for type_cast_attribute.
This is good because it reduces duplication.
2011-12-01 23:41:51 +00:00
Jon Leighton
47b97a739d Fix up test altering global state that was causing me grief 2011-12-01 23:41:51 +00:00
Jon Leighton
3a40d38619 Get rid of the underscore versions of attribute methods!
This makes me happy!
2011-12-01 23:41:51 +00:00
Jon Leighton
3dcb127109 Don't rely on underscore-prefixed attribute methods.
Define singleton methods on the attributes module instead. This reduces
method pollution on the actual model classes. It also seems to make
something faster, I am unsure why! O_o
2011-12-01 23:41:51 +00:00
Jon Leighton
365e10b8dc Remove unnecessary *args 2011-12-01 23:41:51 +00:00
José Valim
07f90f6bec Merge branch 'exceptions' with the following features:
* A Railtie API for registering new exceptions and their respective status code (check Active Record railtie for an example)

* Extraction of ShowExceptions middleware logging and debugging features into a middleware called DebugExceptions

Conflicts:
	actionpack/CHANGELOG.md
2011-12-01 21:18:47 +01:00
José Valim
6a4606d3a6 Remove unnecessary test setup. 2011-12-01 21:17:11 +01:00
José Valim
f9edc079e0 Split and improve show and debug exceptions middlewares. 2011-12-01 21:15:42 +01:00
José Valim
750bb5c865 Split ShowExceptions responsibilities in two middlewares. 2011-12-01 20:46:18 +01:00
David Heinemeier Hansson
83d29a283c Revert "Added ActiveRecord::Base#last_modified to work with the new fresh_when/stale? conditional get methods from Action Pack"
Needless indirection with no added value.

This reverts commit 535853e83b.
2011-12-01 20:45:47 +01:00
José Valim
956ecff833 Add a deprecation to old show exceptions API (even though it was not public). 2011-12-01 20:16:12 +01:00
José Valim
0b677b18ff Add an ExceptionWrapper that wraps an exception and provide convenience helpers. 2011-12-01 20:02:00 +01:00
David Heinemeier Hansson
535853e83b Added ActiveRecord::Base#last_modified to work with the new fresh_when/stale? conditional get methods from Action Pack 2011-12-01 19:47:14 +01:00
José Valim
b4359bc723 Allow rescue responses to be configured through a railtie. 2011-12-01 19:21:35 +01:00
David Heinemeier Hansson
218c272938 Allow fresh_when/stale? to take a record instead of an options hash [DHH] 2011-12-01 19:16:10 +01:00
José Valim
1e51cd957e Update CHANGELOG. 2011-12-01 13:22:28 +01:00
José Valim
f8b934224f Merge pull request #3660 from jdelStrother/asset_protocol
default_asset_host_protocol should not default to :relative
2011-12-01 04:18:41 -08:00
Jonathan del Strother
88237daae4 Leave default_asset_host_protocol unset
When default_asset_host_protocol is left as nil, it will use absolute protocols when a request is present, and relative protocols otherwise (eg in asset generation)
2011-12-01 11:57:33 +00:00
José Valim
cb7145700d Merge pull request #3823 from avakhov/av-length-validation-exception-msg-fix
Fix argument error message for length validation
2011-11-30 22:09:56 -08:00
Alexey Vakhov
814a4c3160 Fix argument error message for length validation 2011-12-01 09:12:16 +04:00
Jon Leighton
52eedf5e2b Add hackery to make Syck use encode_with/init_with. Fixes 1.8 after recent changes to attribute serialization. 2011-12-01 01:15:16 +00:00
Jon Leighton
1c783c6040 don't alter global state in test 2011-11-30 23:47:16 +00:00
Julius de Bruijn
4e380828ff If the table behind has no primary key, do not ask again and just return nil. 2011-11-30 23:47:16 +00:00
Jon Leighton
7a4949e7d5 consistency 2011-11-30 23:18:41 +00:00
Jon Leighton
d5f7884dc5 Don't check column type, you might implement a custom coder that serializes to a different type 2011-11-30 23:18:40 +00:00
Jon Leighton
7895182d0f omg computer science!
Implement a mini state machine for serialized attributes. This means we
do not have to deserialize the values upon initialization, which means
that if we never actually access the attribute, we never have to
deserialize it.
2011-11-30 23:18:40 +00:00
Jon Leighton
4f20eb5908 Fix typo 2011-11-30 23:18:40 +00:00
Jon Leighton
035b4244ba Don't need second param 2011-11-30 23:18:40 +00:00
Jon Leighton
efcc95acb7 No longer need to undef id as we are defining it ourselves 2011-11-30 23:18:40 +00:00
Jon Leighton
6c63f1aa44 Move some serialization stuff out of Base 2011-11-30 23:18:40 +00:00
Jon Leighton
f4853dc174 Extract attribute serialization code into a separate module 2011-11-30 23:18:40 +00:00
Jon Leighton
61489dc684 Use inheritance to avoid special-case code for the 'id' method 2011-11-30 23:18:40 +00:00
Jon Leighton
4c33d517d9 #id is an alias for whatever the primary key is 2011-11-30 23:18:40 +00:00
Jon Leighton
40840aa9ea fix indent 2011-11-30 23:18:40 +00:00
Vijay Dev
cbeeaa6ea0 expand on pluck docs 2011-12-01 01:42:54 +05:30
Vijay Dev
a72839bc9d minor typo fix 2011-12-01 01:42:54 +05:30
Vijay Dev
04b4fe77c9 s/is is/is 2011-12-01 01:42:54 +05:30
Yehuda Katz
a604983f8b Merge pull request #3816 from lest/exception-page-utf-8
fix exception page when template contains utf-8 and parameters contain utf-8
2011-11-30 11:45:18 -08:00
Vijay Dev
0092f0612d Merge pull request #3786 from nashby/add-namespace-to-form
update guides for the namespace option in form helpers
2011-11-30 11:23:37 -08:00
Vijay Dev
9811c3624a fix bad nodocs 2011-12-01 00:34:21 +05:30
lest
13cab6ef50 fix exception page when template contains utf-8 and parameters contain utf-8 2011-11-30 21:51:01 +03:00
Aaron Patterson
5b3d4f0785 switch WatchStack to use composition, tighten up API 2011-11-30 10:17:27 -08:00
Vijay Dev
88daf08258 Merge branch 'master' of github.com:lifo/docrails 2011-11-30 23:32:01 +05:30
José Valim
5b2eb64ceb Revert "Implement ArraySerializer and move old serialization API to a new namespace."
This reverts commit 8896b4fdc8.

Conflicts:

	activemodel/lib/active_model.rb
	activemodel/lib/active_model/serializable.rb
	activemodel/lib/active_model/serializer.rb
	activemodel/test/cases/serializer_test.rb
2011-11-30 18:48:17 +01:00