module DCI::Castable
Public Class Methods
module_method_rebinding?()
click to toggle source
# File lib/dci/castable.rb, line 5 def self.module_method_rebinding? sample_method = Enumerable.instance_method(:to_a) begin !!sample_method.bind(Object.new) rescue TypeError false end end
Private Instance Methods
delegated_method(role, method)
click to toggle source
# File lib/dci/castable.rb, line 17 def delegated_method(role, method) role.instance_method(method) end
method_missing(method, *arguments, &block)
click to toggle source
Calls superclass method
# File lib/dci/castable.rb, line 26 def method_missing(method, *arguments, &block) role = participating_role_with_method(method) role ? delegated_method(role, method).bind(self).call(*arguments, &block) : super end
participating_role_with_method(method)
click to toggle source
# File lib/dci/castable.rb, line 31 def participating_role_with_method(method) context = DCI::Context.current return unless context roles = context[self] return unless roles roles.find do |role| role.public_instance_methods.include?(method) || role.protected_instance_methods.include?(method) || role.private_instance_methods.include?(method) end end
respond_to_missing?(method, include_private)
click to toggle source
Calls superclass method
# File lib/dci/castable.rb, line 45 def respond_to_missing?(method, include_private) !!participating_role_with_method(method) || super end