Sha256: fd3dc28c6b99dad5fe63c03e4740fab84757488acb94ab94d6e14e2a11968096

Contents?: true

Size: 743 Bytes

Versions: 13

Compression:

Stored size: 743 Bytes

Contents

module Perus::Server
    class Config < Sequel::Model
        plugin :validation_helpers
        one_to_many :systems
        one_to_many :config_metrics, order: 'name asc'

        def metric_hashes
            config_metrics.collect(&:config_hash)
        end

        def largest_order
            if config_metrics.empty?
                0
            else
                config_metrics.last.order
            end
        end

        def can_delete?
            systems_dataset.empty?
        end

        def validate
            super
            validates_presence  :name
            validates_unique    :name
        end

        def after_destroy
            super
            config_metrics.each(&:destroy)
        end
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
perus-0.1.15 lib/perus/server/models/config.rb
perus-0.1.14 lib/perus/server/models/config.rb
perus-0.1.13 lib/perus/server/models/config.rb
perus-0.1.12 lib/perus/server/models/config.rb
perus-0.1.11 lib/perus/server/models/config.rb
perus-0.1.10 lib/perus/server/models/config.rb
perus-0.1.9 lib/perus/server/models/config.rb
perus-0.1.8 lib/perus/server/models/config.rb
perus-0.1.7 lib/perus/server/models/config.rb
perus-0.1.6 lib/perus/server/models/config.rb
perus-0.1.5 lib/perus/server/models/config.rb
perus-0.1.4 lib/perus/server/models/config.rb
perus-0.1.3 lib/perus/server/models/config.rb