Module: Rumbly::Model::Abstract
- Included in:
- Application, Attribute, Klass, Operation, Parameter, Relationship
- Defined in:
- lib/rumbly/model/abstract.rb
Overview
The Abstract
module is extended (not included) by abstract subclasses that declare their public attributes and wish to have stub methods for these attributes generated automatically. The stub methods raise an exception with the abstract class name so implementers know that they need to implement the given method(s) in their concrete subclass(es).
Instance Method Summary collapse
-
#stub_required_methods(cls, attributes) ⇒ Object
Creates stub accesor methods for each of the given
attributes
.
Instance Method Details
#stub_required_methods(cls, attributes) ⇒ Object
Creates stub accesor methods for each of the given attributes
. Each method raises a RuntimeError
, since the extending class is meant to be abstract.
13 14 15 16 17 18 19 |
# File 'lib/rumbly/model/abstract.rb', line 13 def stub_required_methods (cls, attributes) attributes.keys.each do |a| = "Method '%s' called on abstract '#{cls.name}' class" define_method(a) { raise ( % a) } define_method("#{a}=") { |x| raise ( % "#{a}=") } end end |