Class: Cuttings::Greenhouse
- Inherits:
-
Object
- Object
- Cuttings::Greenhouse
- Defined in:
- lib/cuttings/greenhouse.rb
Instance Method Summary collapse
- #creatable_models ⇒ Object
- #process ⇒ Object
- #seed(model_name, options = {}, &block) ⇒ Object
- #truncatable_models ⇒ Object
- #truncate(*model_names) ⇒ Object
- #truncate_models ⇒ Object
Instance Method Details
#creatable_models ⇒ Object
16 17 18 |
# File 'lib/cuttings/greenhouse.rb', line 16 def creatable_models @creatable_models ||= [] end |
#process ⇒ Object
20 21 22 23 |
# File 'lib/cuttings/greenhouse.rb', line 20 def process truncate_models creatable_models.each(&:run) end |
#seed(model_name, options = {}, &block) ⇒ Object
3 4 5 6 |
# File 'lib/cuttings/greenhouse.rb', line 3 def seed(model_name, = {}, &block) truncatable_models << model_name unless .delete(:truncate) == false creatable_models << Cutting.new(model_name, , &block) end |
#truncatable_models ⇒ Object
12 13 14 |
# File 'lib/cuttings/greenhouse.rb', line 12 def truncatable_models @truncatable_models ||= [] end |
#truncate(*model_names) ⇒ Object
8 9 10 |
# File 'lib/cuttings/greenhouse.rb', line 8 def truncate(*model_names) truncatable_models.concat(model_names.flatten) end |
#truncate_models ⇒ Object
25 26 27 28 29 |
# File 'lib/cuttings/greenhouse.rb', line 25 def truncate_models truncatable_models.each do |model_name| model_name.constantize.destroy_all end end |