Class: Model
- Inherits:
-
Object
- Object
- Model
- Defined in:
- lib/relationships/model.rb
Instance Attribute Summary collapse
-
#file_contents ⇒ Object
Returns the value of attribute file_contents.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #file_name ⇒ Object
-
#initialize(args = {}) ⇒ Model
constructor
A new instance of Model.
- #relationships ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Model
Returns a new instance of Model.
8 9 10 11 |
# File 'lib/relationships/model.rb', line 8 def initialize(args = {}) @file_path = args[:file] @file_contents = File.read file_path if file_path end |
Instance Attribute Details
#file_contents ⇒ Object
Returns the value of attribute file_contents.
2 3 4 |
# File 'lib/relationships/model.rb', line 2 def file_contents @file_contents end |
#file_path ⇒ Object
Returns the value of attribute file_path.
2 3 4 |
# File 'lib/relationships/model.rb', line 2 def file_path @file_path end |
Class Method Details
.from_file(file) ⇒ Object
4 5 6 |
# File 'lib/relationships/model.rb', line 4 def self.from_file(file) Model.new file: file end |
Instance Method Details
#class_name ⇒ Object
21 22 23 |
# File 'lib/relationships/model.rb', line 21 def class_name file_name[/\w+/].camelize end |
#file_name ⇒ Object
17 18 19 |
# File 'lib/relationships/model.rb', line 17 def file_name file_path[/\w+\.rb/] end |
#relationships ⇒ Object
13 14 15 |
# File 'lib/relationships/model.rb', line 13 def relationships @relationships ||= extract_relationships end |