[rspec-users] newbie cucumber tutorial
lists at ruby-forum.com
Tue Dec 23 21:26:37 EST 2008
Matt Wynne wrote:
> ActiveRecord::Validations uses a trick that's used widely in rails,
> and is arguably becoming a Ruby idiom, apparently.
> This is the interesting bit, around line #275:
> def self.included(base) # :nodoc:
> base.extend ClassMethods
> So basically that means that when the class ActiveRecord::Base
> includes the module ActiveRecord::Validations, that module extends the
> thing which included it (in this case ActiveRecord::Base) with the
> class methods defined in ActiveRecords::Validations::ClassMethods.
> Does that make sense?
um, no. You say that the class ActiveRecord::Base includes the module
ActiveRecord::Validations, but I don't see that in the code I'm looking
If I assume that I'm looking at the wrong code or it happens thru some
magic then you can make a module which will add its class methods to the
class which includes it? Is that some kind of trick to create multiple
inheritance? Is there any way without digging thru source to know which
class include methods from other classes or do y'all just get so cozy
with every Rails class you use that you "just know?"
> I highly recommend reading David A Black's 'Ruby for Rails' at this
> point in your learnings. It did me a world of good when I was
> similarly new to Ruby. It's a really good deep grounding in Ruby IMO.
Just ordered a second-hand copy online. Thanks for the recommendation.
Nice reference, but I didn't fully follow that either and posted a
similar question there.
p.s Good question Tim on the webrat magic. I added a note to the
tutorial that explains where the step was defined.
Posted via http://www.ruby-forum.com/.
More information about the rspec-users