Sha256: 8703937ddb6cc11c5e976232585461b5877a1e899f015a9afd06223c36899650
Contents?: true
Size: 901 Bytes
Versions: 19
Compression:
Stored size: 901 Bytes
Contents
#!/usr/bin/env ruby module Rtt class Client include DataMapper::Resource DEFAULT_NAME = 'default' DEFAULT_DESCRIPTION = 'Default Client' property :id, Serial property :name, String, :required => true, :unique => true, :default => DEFAULT_NAME property :description, String, :default => DEFAULT_DESCRIPTION property :active, Boolean, :default => false has n, :projects #, :through => Resource before :create do |client| client.active = true if Client.all.length == 0 true end def self.default first_or_create :active => true end def self.current_active? first :active => true end def activate deactivate_all self.active = true self.save self end def deactivate_all Client.all.each do |client| client.active = false client.save end end end end
Version data entries
19 entries across 19 versions & 1 rubygems