Class: SeedGimmick::Inflector

Inherits:
Object
  • Object
show all
Defined in:
lib/seed_gimmick/inflector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seed_dir) ⇒ Inflector

Returns a new instance of Inflector.



5
6
7
# File 'lib/seed_gimmick/inflector.rb', line 5

def initialize(seed_dir)
  @seed_dir = seed_dir
end

Instance Attribute Details

#seed_dirObject (readonly)

Returns the value of attribute seed_dir.



3
4
5
# File 'lib/seed_gimmick/inflector.rb', line 3

def seed_dir
  @seed_dir
end

Instance Method Details

#model_for(seed_file) ⇒ Object



9
10
11
# File 'lib/seed_gimmick/inflector.rb', line 9

def model_for(seed_file)
  relative_path(without_ext(seed_file)).to_s.classify.constantize
end

#seed_for(model, format = :yml) ⇒ Object



13
14
15
# File 'lib/seed_gimmick/inflector.rb', line 13

def seed_for(model, format = :yml)
  seed_dir + _pathname(model.model_name.collection).sub_ext(".#{format}")
end