Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/ventouse/module_declarations.rb
Instance Method Summary collapse
-
#declarations(&blk) ⇒ Object
Usage:.
Instance Method Details
#declarations(&blk) ⇒ Object
Usage:
class Model
module ModelAspect
declarations do
has_many :aspect_details
validates_presence_of :main_aspect
etc
end
end
end
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ventouse/module_declarations.rb', line 13 def declarations &blk unless @declaration_blocks @declaration_blocks = [] def self.included mod case mod when Class @declaration_blocks.each {|b| mod.class_eval &b } when Module @declaration_blocks.each {|b| mod.declarations &b } end rescue Exception => ex # When autoloading, you never see real exception unless this rescue puts ex. puts ex.backtrace.join("\n") raise ex end end @declaration_blocks << blk end |