Commit d397630

Stephen Peasley <stephenpeasley@hotmail.com>
2013-09-28 15:02:56
extend runtime object with behaviour defined in a module.
1 parent 56a0392
Changed files (3)
spec/lesson_four/lesson_spec.rb
@@ -3,13 +3,19 @@ require 'spec_helper'
 class Blah
 end
 
+module ExposeBinding
+  def get_binding
+    binding
+  end
+end
+
 module LifeBoat
   class FloatationDevice
   end
 end
 
 module Queryable
-    def matches?
+  def matches?
     each do |item|
       result = yield(item) if block_given?
       return item if result
@@ -29,7 +35,7 @@ end
 
 class Library
   include Queryable
-  
+
   def initialize(books = [])
     @books = books
   end
@@ -75,5 +81,10 @@ describe "modules" do
     it "should return false if the book is not in the library" do
       library.has_book?("george of the jungle").should be_false
     end
+    
+    it "should tell how many books are in the library" do
+      library.extend(Enumerable)
+      library.count.should == 3
+    end
   end
 end
\ No newline at end of file
spec/lesson_three/movie_library_spec.rb
@@ -1,5 +1,10 @@
 require "spec_helper"
 
+#homework
+#move MovieLibrary and Movie to the lib folder (in separate files)
+#separate the include? method into its own module (and whatever else we can)
+#extend one method at run time and another at instantiation time
+
 class Movie
   def initialize(name)
     @name = name
readme.md
@@ -41,3 +41,4 @@
 * solid
 * tdd
 * range
+* lazy (lazy object)