Sha256: 8bd8246ab604d008b9f4cc437eabc7007174200a3eccab863e1ec75a15580517
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
module Zuul module ActiveRecord module RoleSubject def self.included(base) base.send :extend, ClassMethods base.send :include, ContextAccessors end module ClassMethods def self.extended(base) base.send :attr_accessible, :context, :context_id, :context_type, base.auth_scope.role_foreign_key.to_sym, base.auth_scope.subject_foreign_key.to_sym if ::Zuul.should_whitelist? add_validations base add_associations base end def self.add_validations(base) base.send :validates_presence_of, base.auth_scope.role_foreign_key.to_sym, base.auth_scope.subject_foreign_key.to_sym base.send :validates_uniqueness_of, base.auth_scope.role_foreign_key.to_sym, :scope => [base.auth_scope.subject_foreign_key.to_sym, :context_id, :context_type], :case_sensitive => false base.send :validates_numericality_of, base.auth_scope.role_foreign_key.to_sym, base.auth_scope.subject_foreign_key.to_sym, :only_integer => true end def self.add_associations(base) base.send :belongs_to, base.auth_scope.role_singular_key, :class_name => base.auth_scope.role_class_name base.send :belongs_to, base.auth_scope.subject_singular_key, :class_name => base.auth_scope.subject_class_name end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zuul-0.2.8 | lib/zuul/active_record/role_subject.rb |