Advanced Rails - Building Industrial-Strength Web Apps in Record Time
Metaprogramming Techniques | 25 If this were a language without scriptable test fixtures, you might be writing these by hand. Th ...
26 | Chapter 1: Foundational Techniques and continuation-based web frameworks provide an interesting alternative to frame- works ...
Metaprogramming Techniques | 27 def initialize(items) @batcher = Borges::BatchedList.new items, 8 end def render_content_on(r) r ...
28 | Chapter 1: Foundational Techniques def sandbox_binding binding end #... end ScaffoldingSandboxis a class that provides a cl ...
Metaprogramming Techniques | 29 TheObject#methodsmethod returns an array of instance methods, including single- ton methods, def ...
30 | Chapter 1: Foundational Techniques As always, with great power comes great responsibility. Although these methods can be us ...
Metaprogramming Techniques | 31 def age Time.now - self[:initialized_at] end end settings = Settings.new :use_foo_bar => true ...
32 | Chapter 1: Foundational Techniques Another consequence of the functionality being spread around is that it can be diffi- cu ...
Metaprogramming Techniques | 33 obtained through metaprogramming. There is a Ruby proposal for cut-based AOP,* but it may be mon ...
34 | Chapter 1: Foundational Techniques There is a standard Ruby idiom for chaining methods. Assume we have some library code th ...
Metaprogramming Techniques | 35 module ActiveMerchant module Billing module Integrations module ActionViewHelper def payment_ser ...
36 | Chapter 1: Foundational Techniques # for a plugin, these two lines would go in init.rb C.send(:include, M) C.class_eval { a ...
Functional Programming | 37 The most common use for blocks in Ruby is in conjunction with iterators. Many pro- grammers who come ...
38 | Chapter 1: Foundational Techniques reject Returns an array of all items in the collection for which the block evaluates to ...
Functional Programming | 39 Aggregators These methods aggregate or summarize the data. inject(initial) Folds an operation across ...
40 | Chapter 1: Foundational Techniques The signature ofEnumerator.newisEnumerator.new(obj,method,*args), whereobjis the object ...
Examples | 41 That way, we have a smallEnumeratorobject whoseeachmethod behaves just as hash’seach_valuemethod does. This is pre ...
42 | Chapter 1: Foundational Techniques puts "#{method}: #{"%.3f" % (end_time-start_time)} s." end end end end We add singleton ...
Examples | 43 However, there are some disadvantages to writing what is essentially self-modifying code: Tracing is only availab ...
44 | Chapter 1: Foundational Techniques Because of the speed needed in both generation and recognition, the routing code modifie ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf