Class: Editus::Actions
- Inherits:
-
Object
- Object
- Editus::Actions
- Defined in:
- lib/editus/actions.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
4 5 6 7 8 9 |
# File 'lib/editus/actions.rb', line 4 def all con = Editus::FileLib.read( Rails.root.join(Editus.configuration.actions_file_path) ) json_parse(con) end |
.create(action) ⇒ Object
11 12 13 14 15 |
# File 'lib/editus/actions.rb', line 11 def create action actions = all.push(action) path = Rails.root.join(Editus.configuration.actions_file_path) Editus::FileLib.write(path, actions.to_json) end |
.json_parse(con) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/editus/actions.rb', line 23 def json_parse con arr = JSON.parse(con) arr.map do |haction| Action.new(**haction.symbolize_keys) end rescue StandardError [] end |
.remove(action) ⇒ Object
17 18 19 20 21 |
# File 'lib/editus/actions.rb', line 17 def remove action actions = all.push(action) path = Rails.root.join(Editus.configuration.actions_file_path) Editus::FileLib.write(path, actions.to_json) end |