Skip to content

Commit

Permalink
Using def_delegators to shorten code.
Browse files Browse the repository at this point in the history
  • Loading branch information
btakita committed Sep 19, 2009
1 parent b625a8b commit 662e735
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 37 deletions.
1 change: 1 addition & 0 deletions lib/rr.rb
@@ -1,5 +1,6 @@
dir = File.dirname(__FILE__)
require 'rubygems'
require 'forwardable'

require "#{dir}/rr/errors/rr_error"
require "#{dir}/rr/errors/subject_does_not_implement_method_error"
Expand Down
15 changes: 4 additions & 11 deletions lib/rr/method_dispatches/base_method_dispatch.rb
@@ -1,6 +1,7 @@
module RR
module MethodDispatches
class BaseMethodDispatch
extend Forwardable
include Space::Reader

attr_reader :args, :block, :double
Expand Down Expand Up @@ -75,17 +76,9 @@ def double_not_found_error
raise Errors::DoubleNotFoundError, message
end

def after_call_proc
definition.after_call_proc
end

def definition
double.definition
end

def doubles
double_injection.doubles
end
def_delegators :definition, :after_call_proc
def_delegators :double, :definition
def_delegators :double_injection, :doubles
end
end
end
25 changes: 2 additions & 23 deletions lib/rr/method_dispatches/method_dispatch.rb
Expand Up @@ -51,29 +51,8 @@ def call_implementation
end
end

def implementation
definition.implementation
end

def subject_has_original_method?
double_injection.subject_has_original_method?
end

def subject_has_original_method_missing?
double_injection.subject_has_original_method_missing?
end

def subject
double_injection.subject
end

def method_name
double_injection.method_name
end

def original_method_alias_name
double_injection.original_method_alias_name
end
def_delegators :definition, :implementation
def_delegators :double_injection, :subject_has_original_method?, :subject_has_original_method_missing?, :subject, :method_name, :original_method_alias_name
end
end
end
4 changes: 1 addition & 3 deletions lib/rr/method_dispatches/method_missing_dispatch.rb
Expand Up @@ -53,9 +53,7 @@ def double_injection
space.double_injection(subject, method_name)
end

def original_method_missing_alias_name
self.class.original_method_missing_alias_name
end
def_delegators 'self.class', :original_method_missing_alias_name
end
end
end

0 comments on commit 662e735

Please sign in to comment.