Advanced Rails - Building Industrial-Strength Web Apps in Record Time
Ruby Foundations | 5 The classClassinherits fromModule; every class is also a module. However, there is an important distinction ...
6 | Chapter 1: Foundational Techniques Ruby follows the receiver’sklasspointer and searches them_tblof that class object for a ...
Ruby Foundations | 7 The next-simplest case is inheritance from one class. Class inheritance simply fol- lows thesuper pointers. ...
8 | Chapter 1: Foundational Techniques The single-bordered box aroundobjrepresents a plain-old object instance. Note that each b ...
Ruby Foundations | 9 module into a class, Ruby inserts an ICLASS representing the included module into the including class objec ...
10 | Chapter 1: Foundational Techniques We invoke themixed_method method from the mixin, withobjA as the receiver: objA.mixed_me ...
Ruby Foundations | 11 module B include A def hello "Hello from B" end end module C include A def hello "Hello from C" end end cl ...
12 | Chapter 1: Foundational Techniques The singleton class Singleton classes(alsometaclassesoreigenclasses; see the upcoming si ...
Ruby Foundations | 13 TheobjBinstance is of classA, as usual. And if you ask Ruby, it will tell you thatobjA is also of classA: ...
14 | Chapter 1: Foundational Techniques Therefore, it tells us thatobjA’s class isA. This is important to remember: an object’s ...
Ruby Foundations | 15 This should not be a surprise. There is no magic here. Class methods are found in the exact same way as in ...
16 | Chapter 1: Foundational Techniques Theto_smethod has been added toA’s singleton class, orClass:A. Now, whenA.to_s is called ...
Ruby Foundations | 17 # Print the result of calling each method in turn %w(one two three four five six).each do |number| puts A. ...
18 | Chapter 1: Foundational Techniques class Object # The hidden singleton lurks behind everyone def metaclass; class << ...
Ruby Foundations | 19 Variable Lookup There are four types of variables in Ruby: global variables, class variables, instance var ...
20 | Chapter 1: Foundational Techniques Class variables can be somewhat confusing to use. They are shared all the way down the i ...
Ruby Foundations | 21 add_3.to_proc # => #<Proc:0x00024b08@-:6> add_3.call(5) # => 8 # Method#[] is a handy synonym ...
22 | Chapter 1: Foundational Techniques lambda_proc.call # => 3 proc_new_proc.call # => puts "Never reached" end block_tes ...
Metaprogramming Techniques | 23 A classic example of closures is themake_counterfunction, which returns a counter function (aPro ...
24 | Chapter 1: Foundational Techniques def method_missing(method_id, *args, &block) ... end There are several drawbacks to ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf