Class: CustomSeeds::SeedList
- Inherits:
-
Object
- Object
- CustomSeeds::SeedList
- Includes:
- Enumerable
- Defined in:
- lib/custom_seeds/seed_list.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(directory: nil) ⇒ SeedList
constructor
A new instance of SeedList.
- #seeds ⇒ Object
Constructor Details
#initialize(directory: nil) ⇒ SeedList
Returns a new instance of SeedList.
16 17 18 |
# File 'lib/custom_seeds/seed_list.rb', line 16 def initialize(directory: nil) @directory = directory || ::Rails.root.join('db/seeds/') end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
5 6 7 |
# File 'lib/custom_seeds/seed_list.rb', line 5 def directory @directory end |
Instance Method Details
#each(&block) ⇒ Object
29 30 31 |
# File 'lib/custom_seeds/seed_list.rb', line 29 def each(&block) seeds.each(&block) end |
#seeds ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/custom_seeds/seed_list.rb', line 20 def seeds @seeds ||= Dir.glob("#{directory}/**/*.rb").map do |filename| namespaces = namespaces_for(filename) task_name = taskname_for(filename) Item.new(filename, (namespaces + [task_name]).join(':').intern) end end |