Top Level Namespace
Defined Under Namespace
Modules: ReactRailsAPI
Instance Method Summary collapse
-
#modify_json(file) {|hash| ... } ⇒ Object
Allows for modification of JSON files.
-
#template(name) ⇒ Object
Loads a template from ./templates.
Instance Method Details
#modify_json(file) {|hash| ... } ⇒ Object
Allows for modification of JSON files
10 11 12 13 14 |
# File 'lib/react-rails-api/template.rb', line 10 def modify_json(file) hash = JSON.parse File.read(file), symbolize_names: true yield hash if block_given? File.open(file, ?w) {|f| f.write JSON.pretty_generate(hash)} end |
#template(name) ⇒ Object
Loads a template from ./templates
5 6 7 |
# File 'lib/react-rails-api/template.rb', line 5 def template(name) File.open(File.join __dir__, 'templates', name).read end |