Class: Group

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/usvn/usvn_0_x.rb

Overview

usvn_groups --------------------—————------—–---------—————-+ | Field | Type | Null | Key | Default | Extra | --------------------—————------—–---------—————-+ | groups_id | int(11) | NO | PRI | NULL | auto_increment | | groups_name | varchar(150) | NO | UNI | NULL | | | groups_description | varchar(1000) | YES | | NULL | | --------------------—————------—–---------—————-+

Class Method Summary collapse

Class Method Details

.create_or_update(names) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/usvn/usvn_0_x.rb', line 47

def self.create_or_update(names)
  groups = []
  names.each do |name|
    name.strip!
    if name =~ /^[a-zA-Z0-9\-\_]+$/
      g = Group.first(:name => name)
      if g.nil?
        g = Group.create(:name => name)
      end
      groups << g
    end
  end
  groups
end