Module: ActiveFixture::Loader::ClassMethods
- Defined in:
- lib/active_fixture/loader.rb
Instance Method Summary collapse
- #fixture_path(clazz) ⇒ Object
- #has_fixture?(clazz) ⇒ Boolean
- #inherited(base) ⇒ Object
- #load_fixtures(clazz) ⇒ Object
Instance Method Details
#fixture_path(clazz) ⇒ Object
28 29 30 |
# File 'lib/active_fixture/loader.rb', line 28 def fixture_path(clazz) "#{Rails.root}/config/fixtures/#{clazz.name.underscore.pluralize}.yml" end |
#has_fixture?(clazz) ⇒ Boolean
24 25 26 |
# File 'lib/active_fixture/loader.rb', line 24 def has_fixture?(clazz) File.exist? fixture_path(clazz) end |
#inherited(base) ⇒ Object
13 14 15 |
# File 'lib/active_fixture/loader.rb', line 13 def inherited(base) self.load_fixtures(base) end |
#load_fixtures(clazz) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/active_fixture/loader.rb', line 17 def load_fixtures(clazz) if has_fixture?(clazz) source = YAML.load_file(fixture_path(clazz)).with_indifferent_access clazz.fixtures = source[clazz.name.underscore.pluralize] end end |