Module: Inform::AdapterClassDelegation

Included in:
Link, Module, Object, Tag
Defined in:
lib/story_teller/inform/base.rb

Overview

module AdapterClassDelegation

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **kwargs, &block) ⇒ Object



38
39
40
41
42
43
# File 'lib/story_teller/inform/base.rb', line 38

def method_missing(method_name, *args, **kwargs, &block)
  klass = delegated_adapter_class
  return klass.public_send(method_name, *args, **kwargs, &block) if !klass.nil? && klass.respond_to?(method_name)

  super
end

Instance Method Details

#===(other) ⇒ Object



33
34
35
36
# File 'lib/story_teller/inform/base.rb', line 33

def ===(other)
  klass = delegated_adapter_class
  super || (!klass.nil? && other.is_a?(klass))
end

#delegated_adapter_classObject



26
27
28
29
30
31
# File 'lib/story_teller/inform/base.rb', line 26

def delegated_adapter_class
  klass = adapter_class
  klass.equal?(self) ? nil : klass
rescue NotImplementedError
  nil
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/story_teller/inform/base.rb', line 45

def respond_to_missing?(method_name, include_private = false)
  klass = delegated_adapter_class
  (!klass.nil? && klass.respond_to?(method_name, include_private)) || super
end