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


45
46
47
48
49
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 45

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:


51
52
53
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 51

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

#raise_abstract_method(method_name) ⇒ Object

Raises:

  • (::NoMethodError)

55
56
57
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 55

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

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

Returns:


41
42
43
# File 'lib/eac_ruby_utils/abstract_methods.rb', line 41

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