Skip to content

Commit

Permalink
Renamed ClassInstanceMethodDefined.call to ClassInstanceMethodDefined…
Browse files Browse the repository at this point in the history
…#class_instance_method_defined.
  • Loading branch information
Brian Takita committed Oct 28, 2010
1 parent c3d2ef1 commit 1764412
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/rr.rb
@@ -1,6 +1,7 @@
dir = File.dirname(__FILE__)
require 'forwardable'

require "#{dir}/rr/class_instance_method_defined"
require "#{dir}/rr/blank_slate"

require "#{dir}/rr/errors/rr_error"
Expand Down Expand Up @@ -47,7 +48,6 @@
require "#{dir}/rr/hash_with_object_id_key"
require "#{dir}/rr/recorded_calls"
require "#{dir}/rr/proc_from_block"
require "#{dir}/rr/class_instance_method_defined"

require "#{dir}/rr/double_definitions/double_definition_create_blank_slate"
require "#{dir}/rr/double_definitions/double_definition_create"
Expand Down
2 changes: 1 addition & 1 deletion lib/rr/class_instance_method_defined.rb
@@ -1,6 +1,6 @@
module RR
module ClassInstanceMethodDefined
def self.call(klass, instance_method, include_super=true)
def class_instance_method_defined(klass, instance_method, include_super=true)
klass.instance_methods(include_super).detect {|method_name| method_name.to_sym == instance_method.to_sym} ||
klass.protected_instance_methods(include_super).detect {|method_name| method_name.to_sym == instance_method.to_sym} ||
klass.private_instance_methods(include_super).detect {|method_name| method_name.to_sym == instance_method.to_sym}
Expand Down
3 changes: 2 additions & 1 deletion lib/rr/injections/double_injection.rb
Expand Up @@ -83,6 +83,7 @@ def instances
end
end
end)
include ClassInstanceMethodDefined

attr_reader :subject_class, :method_name, :doubles

Expand Down Expand Up @@ -178,7 +179,7 @@ def dispatch_original_method(subject, args, block)
end

def subject_has_original_method_missing?
ClassInstanceMethodDefined.call(subject_class, MethodDispatches::MethodMissingDispatch.original_method_missing_alias_name)
class_instance_method_defined(subject_class, MethodDispatches::MethodMissingDispatch.original_method_missing_alias_name)
end

def original_method_alias_name
Expand Down
5 changes: 3 additions & 2 deletions lib/rr/injections/injection.rb
Expand Up @@ -8,9 +8,10 @@ def instances
end)

include Space::Reader
include ClassInstanceMethodDefined

def subject_has_method_defined?(method_name_in_question)
ClassInstanceMethodDefined.call(subject_class, method_name_in_question)
class_instance_method_defined(subject_class, method_name_in_question)
end

def subject_has_original_method?
Expand All @@ -20,7 +21,7 @@ def subject_has_original_method?
protected
def subject_respond_to_method?(subject, method_name)
subject_has_method_defined?(method_name) ||
ClassInstanceMethodDefined.call(subject_class, :respond_to?) &&
class_instance_method_defined(subject_class, :respond_to?) &&
subject.respond_to?(method_name)
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/rr/injections/method_missing_injection.rb
Expand Up @@ -12,6 +12,7 @@ def exists?(subject)
instances.include?(subject)
end
end)
include ClassInstanceMethodDefined

attr_reader :subject_class
def initialize(subject_class)
Expand All @@ -20,8 +21,8 @@ def initialize(subject_class)
end

def bind
unless ClassInstanceMethodDefined.call(subject_class, original_method_alias_name)
unless ClassInstanceMethodDefined.call(subject_class, :method_missing)
unless class_instance_method_defined(subject_class, original_method_alias_name)
unless class_instance_method_defined(subject_class, :method_missing)
@placeholder_method_defined = true
subject_class.class_eval do
def method_missing(method_name, *args, &block)
Expand Down
5 changes: 3 additions & 2 deletions lib/rr/injections/singleton_method_added_injection.rb
Expand Up @@ -16,6 +16,7 @@ def exists?(subject)
instances.include?(subject)
end
end)
include ClassInstanceMethodDefined

attr_reader :subject_class
def initialize(subject_class)
Expand All @@ -24,8 +25,8 @@ def initialize(subject_class)
end

def bind
unless ClassInstanceMethodDefined.call(subject_class, original_method_alias_name, false)
unless ClassInstanceMethodDefined.call(subject_class, :singleton_method_added, false)
unless class_instance_method_defined(subject_class, original_method_alias_name, false)
unless class_instance_method_defined(subject_class, :singleton_method_added, false)
@placeholder_method_defined = true
subject_class.class_eval do
def singleton_method_added(method_name)
Expand Down

0 comments on commit 1764412

Please sign in to comment.