Class: Perus::Server::Script
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Perus::Server::Script
- Defined in:
- lib/perus/server/models/script.rb
Instance Method Summary collapse
- #after_destroy ⇒ Object
- #can_delete? ⇒ Boolean
- #code_name ⇒ Object
- #config_hash ⇒ Object
- #largest_order ⇒ Object
- #validate ⇒ Object
Instance Method Details
#after_destroy ⇒ Object
39 40 41 42 |
# File 'lib/perus/server/models/script.rb', line 39 def after_destroy super script_commands.each(&:destroy) end |
#can_delete? ⇒ Boolean
29 30 31 |
# File 'lib/perus/server/models/script.rb', line 29 def can_delete? actions_dataset.empty? end |
#code_name ⇒ Object
7 8 9 |
# File 'lib/perus/server/models/script.rb', line 7 def code_name name.gsub(' ', '_').camelize end |
#config_hash ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/perus/server/models/script.rb', line 11 def config_hash { id: id, type: 'Script', options: { commands: script_commands.collect(&:config_hash) } } end |
#largest_order ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/perus/server/models/script.rb', line 21 def largest_order if script_commands.empty? 0 else script_commands.last.order end end |
#validate ⇒ Object
33 34 35 36 37 |
# File 'lib/perus/server/models/script.rb', line 33 def validate super validates_presence :name validates_unique :name end |