module FixtureOverlord::Helpers
Public Instance Methods
persisted_model?(file)
click to toggle source
check to see if the model is inherited from ActiveRecord
TODO: Add more than just ActiveRecord, specifically Sequel
# File lib/fixture_overlord/helpers.rb, line 24 def persisted_model?(file) model = to_model(file) model.respond_to?(:superclass) && model.superclass == ::ActiveRecord::Base end
respond_to_model_methods?(model)
click to toggle source
# File lib/fixture_overlord/helpers.rb, line 29 def respond_to_model_methods?(model) model.respond_to?(:create!) || model.respond_to?(:create) || model.respond_to?(:build) end
to_model(file)
click to toggle source
take the yaml filename and convert it to a model classname
# File lib/fixture_overlord/helpers.rb, line 15 def to_model(file) model = yaml_filename(file).to_s.classify.constantize model end
yaml_filename(file)
click to toggle source
reading the yaml filename
# File lib/fixture_overlord/helpers.rb, line 10 def yaml_filename(file) ::File.basename(file).split('.').first end