Module: FixtureOverlord::Helpers
Instance Method Summary collapse
-
#persisted_model?(file) ⇒ Boolean
check to see if the model is inherited from ActiveRecord.
- #respond_to_model_methods?(model) ⇒ Boolean
-
#to_model(file) ⇒ Object
take the yaml filename and convert it to a model classname.
-
#yaml_filename(file) ⇒ Object
reading the yaml filename.
Instance Method Details
#persisted_model?(file) ⇒ Boolean
check to see if the model is inherited from ActiveRecord
TODO: Add more than just ActiveRecord, specifically Sequel
25 26 27 28 |
# File 'lib/fixture_overlord/helpers.rb', line 25 def persisted_model?(file) model = to_model(file) model.respond_to?(:superclass) && model.superclass == ::ActiveRecord::Base end |
#respond_to_model_methods?(model) ⇒ Boolean
30 31 32 |
# File 'lib/fixture_overlord/helpers.rb', line 30 def respond_to_model_methods?(model) model.respond_to?(:create!) || model.respond_to?(:create) || model.respond_to?(:build) end |
#to_model(file) ⇒ Object
take the yaml filename and convert it to a model classname
16 17 18 19 |
# File 'lib/fixture_overlord/helpers.rb', line 16 def to_model(file) model = yaml_filename(file).to_s.classify.constantize model end |
#yaml_filename(file) ⇒ Object
reading the yaml filename
11 12 13 |
# File 'lib/fixture_overlord/helpers.rb', line 11 def yaml_filename(file) ::File.basename(file).split('.').first end |