Sha256: 0e746006b6ae3bcc93aef70913ea52fc727f225fc696a49699b4008ae49b89c8
Contents?: true
Size: 965 Bytes
Versions: 28
Compression:
Stored size: 965 Bytes
Contents
module Perus::Server class Script < Sequel::Model plugin :validation_helpers one_to_many :script_commands, order: :order 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
28 entries across 28 versions & 1 rubygems