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



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

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:



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

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

#raise_abstract_method(method_name) ⇒ Object

Raises:



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

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:



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

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