Module: EacRubyUtils::AbstractMethods::InstanceMethods

Defined in:
lib/eac_ruby_utils/abstract_methods.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



52
53
54
55
56
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 52

def method_missing(method_name, *arguments, &block)
  raise_abstract_method(method_name) if abstract_method?(method_name)

  super
end

Instance Method Details

#abstract_method?(method_name) ⇒ Boolean

Returns:



58
59
60
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 58

def abstract_method?(method_name)
  self.class.abstract_methods.include?(method_name.to_sym)
end

#raise_abstract_method(method_name) ⇒ Object

Raises:

  • (::NoMethodError)


62
63
64
65
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 62

def raise_abstract_method(method_name)
  raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\"" \
    " (Class: #{self.class})"
end

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

Returns:



48
49
50
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 48

def respond_to_missing?(method_name, include_private = false)
  super || abstract_method?(method_name)
end