Module: EacRubyUtils::ActsAsAbstract::InstanceMethods
- Defined in:
- lib/eac_ruby_utils/acts_as_abstract.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
79
80
81
82
83
|
# File 'lib/eac_ruby_utils/acts_as_abstract.rb', line 79
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
87
88
89
90
91
|
# File 'lib/eac_ruby_utils/acts_as_abstract.rb', line 87
def abstract_method?(method_name)
return false if self.class.method_defined?(method_name)
self.class.send(:abstract_methods_hash).key?(method_name.to_sym)
end
|
#raise_abstract_method(method_name, arguments = []) ⇒ Object
93
94
95
96
97
|
# File 'lib/eac_ruby_utils/acts_as_abstract.rb', line 93
def raise_abstract_method(method_name, arguments = [])
raise ::EacRubyUtils::UnimplementedMethodError,
"Abstract method #{method_name}(#{arguments.join(', ')}) hit in " \
"#{self}\" (Class: #{self.class})"
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
75
76
77
|
# File 'lib/eac_ruby_utils/acts_as_abstract.rb', line 75
def respond_to_missing?(method_name, include_private = false)
super || abstract_method?(method_name)
end
|