1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

23 commits

Author SHA1 Message Date
Aaron Patterson
8eb7561ac6 initialize generated modules on inclusion and on inheritence 2013-07-02 17:11:35 -07:00
Aaron Patterson
6e43fcb333 remove private attribute reader 2013-07-02 15:43:29 -07:00
Aaron Patterson
e086ff5635 just construct real objects rather than mock and stub 2013-06-17 10:50:11 -07:00
Jan Berdajs
89c9ff8d8b add test for 9041454def 2013-06-05 19:53:17 +02:00
Jon Leighton
9e4c41c903 Remove ActiveRecord::Model
In the end I think the pain of implementing this seamlessly was not
worth the gain provided.

The intention was that it would allow plain ruby objects that might not
live in your main application to be subclassed and have persistence
mixed in. But I've decided that the benefit of doing that is not worth
the amount of complexity that the implementation introduced.
2012-10-26 15:51:02 +01:00
Xavier Noria
447b6a4e67 removes usage of Object#in? from the code base (the method remains defined by Active Support)
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in

    5ea6b0df9a

we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.

In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
2012-08-06 00:30:02 +02:00
Xavier Noria
5ea6b0df9a load active_support/core_ext/object/inclusion in active_support/rails 2012-08-02 21:59:22 +02:00
Jon Leighton
e030f26ad3 Simplify AR configuration code.
Get rid of ActiveModel::Configuration, make better use of
ActiveSupport::Concern + class_attribute, etc.
2012-06-15 19:15:36 +01:00
Carlos Antonio da Silva
f50c160cd0 Deprecate Column#type_cast_code 2012-03-29 23:04:51 -03:00
Jon Leighton
30b0e5848c Fix another race condition.
From 2c667f69aa.

Thanks @pwnall for the heads-up.
2012-01-20 18:32:27 +00:00
Jon Leighton
93c1f11c0a Support configuration on ActiveRecord::Model.
The problem: We need to be able to specify configuration in a way that
can be inherited to models that include ActiveRecord::Model. So it is
no longer sufficient to put 'top level' config on ActiveRecord::Base,
but we do want configuration specified on ActiveRecord::Base and
descendants to continue to work.

So we need something like class_attribute that can be defined on a
module but that is inherited when ActiveRecord::Model is included.

The solution: added ActiveModel::Configuration module which provides a
config_attribute macro. It's a bit specific hence I am not putting this
in Active Support or making it a 'public API' at present.
2011-12-28 18:27:41 +00:00
Jon Leighton
ba7ec73f6a Deal with global config better between AR::Base and AR::Model 2011-12-24 11:08:15 +00:00
Jon Leighton
7293cac854 Extract common logic into a method 2011-12-24 11:08:15 +00:00
Jon Leighton
f1eb98f0fc Fix #4046. 2011-12-23 18:20:35 +00:00
Jon Leighton
17ad71e514 Let AttributeMethods do its own including etc 2011-12-15 20:45:42 +00:00
Jon Leighton
64747654ca Revert "Raise error on unknown primary key."
This reverts commit ee2be435b1.
2011-10-05 20:21:21 +01:00
Jon Leighton
ee2be435b1 Raise error on unknown primary key.
If we don't have a primary key when we ask for it, it's better to fail
fast. Fixes GH #2307.
2011-10-05 01:11:40 +01:00
Jon Leighton
eecfa84a90 Always generate attribute methods on the base class.
This fixes a situation I encountered where a subclass would cache the
name of a generated attribute method in @_defined_class_methods. Then,
when the superclass has it's attribute methods undefined, the subclass
would always have to dispatch through method_missing, because the
presence of the attribute in @_defined_class_methods would mean that it
is never generated again, even if undefine_attribute_methods is called
on the subclass.

There various other confusing edge cases like this. STI classes share
columns, so let's just keep all the attribute method generation state
isolated to the base class.
2011-09-13 00:01:58 +01:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. 2011-06-04 23:47:03 +01:00
Prem Sichanugrist
a9f3c9da01 Using Object#in? and Object#either? in various places
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
2011-04-11 03:17:09 +08:00
Aaron Patterson
8657826f41 oops, no need for puts! 2011-02-18 15:53:54 -08:00
Aaron Patterson
30679bc705 AR::AttributeMethods does not need to be included in an AR::Base class. 2011-02-18 15:51:39 -08:00