Module: Seedify::Callbacks
- Included in:
- Base
- Defined in:
- lib/seedify/callbacks.rb
Constant Summary collapse
- TYPES =
%w{before_all}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.with_callbacks(proc) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/seedify/callbacks.rb', line 5 def self.with_callbacks(proc) @finished_before_all ||= [] proc.class.get_callbacks(:before_all).each do |callback| unless @finished_before_all.include?(callback) @finished_before_all << callback proc.send(callback) end end yield end |
Instance Method Details
#get_callbacks(type) ⇒ Object
37 38 39 |
# File 'lib/seedify/callbacks.rb', line 37 def get_callbacks(type) Array((@callbacks || {})[type.to_s]) end |
#inherited(subclass) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/seedify/callbacks.rb', line 19 def inherited(subclass) super TYPES.each do |type| get_callbacks(type).each do |callback| subclass.send(type, callback) end end end |