Class: FeduxOrgStdlib::FixturesManagement::FixturesManager
- Inherits:
-
Object
- Object
- FeduxOrgStdlib::FixturesManagement::FixturesManager
- Defined in:
- lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
Overview
Fixture manager
Instance Method Summary collapse
-
#add(path) ⇒ Object
Add fixture.
-
#find(name) ⇒ Object
Find fixture.
-
#initialize(creator: Fixture, null_klass: NoFixture) ⇒ FixturesManager
constructor
A new instance of FixturesManager.
-
#load_fixtures(path) ⇒ Object
Load fixtures found at path.
-
#to_s ⇒ Object
String representation.
Constructor Details
#initialize(creator: Fixture, null_klass: NoFixture) ⇒ FixturesManager
Returns a new instance of FixturesManager.
12 13 14 15 16 |
# File 'lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb', line 12 def initialize(creator: Fixture, null_klass: NoFixture) @fixtures = Set.new @creator = creator @null_klass = null_klass end |
Instance Method Details
#add(path) ⇒ Object
Add fixture
30 31 32 |
# File 'lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb', line 30 def add(path) fixtures << creator.new(path) end |
#find(name) ⇒ Object
Find fixture
35 36 37 38 39 |
# File 'lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb', line 35 def find(name) name = name.to_sym fixtures.find(null_klass.new(name)) { |f| f.name == name } end |
#load_fixtures(path) ⇒ Object
Load fixtures found at path
19 20 21 22 23 24 25 26 27 |
# File 'lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb', line 19 def load_fixtures(path) path = Pathname.new(path) path.entries.each do |f| next if f.to_s[/^\.\.?/] add f.(path) end end |
#to_s ⇒ Object
String representation
42 43 44 45 |
# File 'lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb', line 42 def to_s data = frontend_components.sort.reduce([]) { |a, e| a << { name: e.name, path: e.path } } List.new(data).to_s end |