Commit 0d738ba

mo khan <mo@mokhan.ca>
2013-05-18 00:50:43
clean up requires and move from booty namespace to spank
1 parent 883ac7f
lib/spank/component.rb
@@ -1,7 +1,4 @@
-require 'lambda_behaviours'
-require "interceptor_registration"
-
-module Booty
+module Spank
   class Component
     include LambdaBehaviours
 
lib/spank/container.rb
@@ -1,6 +1,4 @@
-require 'component'
-
-module Booty
+module Spank
   class ContainerError < Exception
     def intialize(message)
       @message = message
@@ -47,7 +45,7 @@ module Booty
       begin
         lambda.call
       rescue => e
-        raise Booty::ContainerError.new(error ||= "Oops: #{e}")
+        raise Spank::ContainerError.new(error ||= "Oops: #{e}")
       end
     end
   end
lib/spank/interceptor_registration.rb
@@ -1,6 +1,4 @@
-require 'proxy'
-
-module Booty
+module Spank
   class InterceptorRegistration
     def initialize(method_symbol)
       @method = method_symbol
lib/spank/invocation.rb
@@ -1,4 +1,4 @@
-module Booty
+module Spank
   class Invocation
     attr_reader :instance, :method, :arguments, :result
 
lib/spank/ioc.rb
@@ -1,4 +1,4 @@
-module Booty
+module Spank
   class IOC
     def self.bind_to(container)
       @@container = container
lib/spank/lambda_behaviours.rb
@@ -0,0 +1,7 @@
+module Spank
+  module LambdaBehaviours
+    def memoize(lambda_method)
+      lambda { |container| @cache ||= lambda_method.call(container) }
+    end
+  end
+end
lib/spank/proxy.rb
@@ -1,6 +1,4 @@
-require 'invocation'
-
-module Booty
+module Spank
   class Proxy
     def initialize(target)
       @target = target
lib/spank.rb
@@ -3,5 +3,5 @@ require 'spank/container.rb'
 require 'spank/interceptor_registration.rb'
 require 'spank/invocation.rb'
 require 'spank/ioc.rb'
+require 'spank/lambda_behaviours.rb'
 require 'spank/proxy.rb'
-
spec/unit/proxy_spec.rb
@@ -1,6 +1,6 @@
 require "spec_helper"
 
-module Booty
+module Spank
   describe Proxy do
     let(:sut) { Proxy.new(target) }
     let(:target) { fake }