changeset 26:d50ff917c163

Change function calls so methods get patched in anyway
author IBBoard <dev@ibboard.co.uk>
date Fri, 20 Jan 2017 21:03:13 +0000
parents e26607247dd2
children 2ea3b5e9b41b
files 1-Ruby/acts_as_csv_module.rb
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/1-Ruby/acts_as_csv_module.rb	Fri Jan 20 21:01:09 2017 +0000
+++ b/1-Ruby/acts_as_csv_module.rb	Fri Jan 20 21:03:13 2017 +0000
@@ -9,6 +9,9 @@
 module ActsAsCsv
   def self.included(base)
     base.extend ClassMethods
+    # The book doesn't do this, but it is possible to add the methods
+    # without having the inheriting class call a second function to do it
+    base.acts_as_csv
   end
   
   module ClassMethods
@@ -38,7 +41,7 @@
 
 class RubyCsv  # no inheritance! You can mix it in
   include ActsAsCsv
-  acts_as_csv
+  # Also, nothing to do beyond the "include" - it automatically defines the methods!
 end
 
 m = RubyCsv.new