Sha256: f37d13c68f72baa5d828452a2c2d461ae115a6565b8d6df7fd94e5e73929a641
Contents?: true
Size: 866 Bytes
Versions: 76
Compression:
Stored size: 866 Bytes
Contents
class Permissao < ActiveRecord::Base belongs_to :papel validates :klass, presence: true before_save :define_permissioes def abilities ability = [] if can_manage ability << :manage if can_manage else ability << :read if can_read ability << :create if can_create ability << :update if can_update ability << :destroy if can_destroy ability << :create_or_update if can_create or can_update end ability end private def define_permissioes if self.can_create || self.can_update || self.can_destroy self.can_read = true end if !self.can_read || !self.can_create || !self.can_update || !self.can_destroy self.can_manage = false end if self.can_read && self.can_create && self.can_update && self.can_destroy self.can_manage = true end return true end end
Version data entries
76 entries across 76 versions & 1 rubygems