Class: DhEasy::Router::Seeder
- Inherits:
-
Object
- Object
- DhEasy::Router::Seeder
- Includes:
- Plugin::Router
- Defined in:
- lib/dh_easy/router/seeder.rb
Overview
Seeder router designed to execute all seeders classes.
Instance Attribute Summary
Attributes included from Plugin::Router
Instance Method Summary collapse
-
#route(opts = {}) ⇒ Object
Execute the seeder class with options as described by router configuration and calling class’s instance ‘seed` method.
Methods included from Plugin::Router
#class_defined?, #config, #get_class, #initialize, #initialize_hook_router_plugin_router
Instance Method Details
#route(opts = {}) ⇒ Object
Note:
Requires the route class to implement ‘seed` instance method.
Execute the seeder class with options as described by router
configuration and calling class's instance `seed` method.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dh_easy/router/seeder.rb', line 19 def route opts = {} context = opts[:context] if opts[:context].nil? raise ArgumentError.new('Must send a context to the seeder.') end class_name = nil config['seeder']['routes'].each do |item| # Validate class name executor_class = get_class item['class'] if executor_class.nil? raise NameError.new("Class \"#{item['class']}\" doesn't exists, check your dh_easy config file.") end executor_class.new(opts).seed end end |