Sha256: dc161746fe6c1cb1e48b8651b63bbb744ed28c6cf136b899b31d902c219a96de
Contents?: true
Size: 969 Bytes
Versions: 13
Compression:
Stored size: 969 Bytes
Contents
module Perus::Server class Script < Sequel::Model plugin :validation_helpers one_to_many :script_commands, order: 'name asc' one_to_many :actions def code_name name.gsub(' ', '_').camelize end def config_hash { id: id, type: 'Script', options: { commands: script_commands.collect(&:config_hash) } } end def largest_order if script_commands.empty? 0 else script_commands.last.order end end def can_delete? actions_dataset.empty? end def validate super validates_presence :name validates_unique :name end def after_destroy super script_commands.each(&:destroy) end end end
Version data entries
13 entries across 13 versions & 1 rubygems