Class: AnnotateModel::ModelFile
- Inherits:
-
Object
- Object
- AnnotateModel::ModelFile
- Defined in:
- lib/annotate_model/model_file.rb
Instance Method Summary collapse
-
#initialize(file_path) ⇒ ModelFile
constructor
Initializes a new ModelFile instance.
-
#model_name ⇒ String
Returns the model name corresponding to the model file path.
- #relative_path ⇒ Object
-
#table_name ⇒ String
Returns the table name corresponding to the model file path.
- #to_s ⇒ Object
Constructor Details
#initialize(file_path) ⇒ ModelFile
Initializes a new ModelFile instance.
6 7 8 |
# File 'lib/annotate_model/model_file.rb', line 6 def initialize(file_path) @file_path = file_path end |
Instance Method Details
#model_name ⇒ String
Returns the model name corresponding to the model file path.
21 22 23 |
# File 'lib/annotate_model/model_file.rb', line 21 def model_name @file_path.relative_path_from(Rails.root.join('app', 'models')).to_s.sub('.rb', '').camelize end |
#relative_path ⇒ Object
10 11 12 |
# File 'lib/annotate_model/model_file.rb', line 10 def relative_path @file_path.relative_path_from(Rails.root).to_s end |
#table_name ⇒ String
Returns the table name corresponding to the model file path.
32 33 34 |
# File 'lib/annotate_model/model_file.rb', line 32 def table_name @file_path.relative_path_from(Rails.root.join('app', 'models')).to_s.sub('.rb', '').classify.tableize.sub('/', '_') end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/annotate_model/model_file.rb', line 36 def to_s @file_path.to_s end |