Class: Molecule::File
- Inherits:
-
Object
- Object
- Molecule::File
- Defined in:
- lib/molecule/file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ File
constructor
A new instance of File.
- #molecule_file_path ⇒ Object
- #read ⇒ Object
- #read_file ⇒ Object
Constructor Details
#initialize(name) ⇒ File
Returns a new instance of File.
8 9 10 |
# File 'lib/molecule/file.rb', line 8 def initialize name @name = name.to_s end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/molecule/file.rb', line 6 def name @name end |
Instance Method Details
#molecule_file_path ⇒ Object
22 23 24 |
# File 'lib/molecule/file.rb', line 22 def molecule_file_path Rails.root.join('app', 'molecules', @name, 'molecule.json').to_s end |
#read ⇒ Object
12 13 14 |
# File 'lib/molecule/file.rb', line 12 def read JSON.parse(read_file, symbolize_names: true) end |
#read_file ⇒ Object
16 17 18 19 20 |
# File 'lib/molecule/file.rb', line 16 def read_file ::File.read(molecule_file_path) rescue '{}' end |