Sha256: e2f993260985a28a376262cccd39856fa12fd913c37b651010b63d4917e8df47

Contents?: true

Size: 996 Bytes

Versions: 4

Compression:

Stored size: 996 Bytes

Contents

#:nodoc:
module Users
  #:nodoc:
  module Models
    ##
    # Model that represents a single user group. This model has the following
    # relations:
    #
    # * users (many to many)
    # * access rules (one to many)
    #
    # This model uses the following plugins:
    #
    # * sluggable
    # 
    # @author Yorick Peterse
    # @since  0.1
    #
    class UserGroup < Sequel::Model
      many_to_many(:users      , :class => "Users::Models::User")
      one_to_many(:access_rules, :class => "Users::Models::AccessRule")
      
      plugin :sluggable , :source => :name, :freeze => false
      
      ##
      # Validation rules for each user group used when
      # creating or updating a group.
      #
      # @author Yorick Peterse
      # @since  0.1
      #
      def validate
        validates_presence [:name, :super_group]
        validates_presence :slug unless new?
        validates_unique   :slug

        validates_type TrueClass, :super_group
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.2.4.1 lib/zen/package/users/lib/users/model/user_group.rb
zen-0.2.4 lib/zen/package/users/lib/users/model/user_group.rb
zen-0.2.3 lib/zen/package/users/lib/users/model/user_group.rb
zen-0.2 lib/zen/package/users/lib/users/model/user_group.rb