Module: PrivatePerson::ActsAsPermissible::ClassMethods

Defined in:
lib/private_person/extensions/acts_as_permissible.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_permissible(params = {}) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/private_person/extensions/acts_as_permissible.rb', line 7

def acts_as_permissible(params = {})
  if params[:by].nil?
    raise 'Called acts_as_permissible, but without a :by parameter.'
  end
  class_attribute :by
  self.by = params[:by]

  has_many :permissions, :as => :permissible, :class_name => 'PrivatePerson::Permission'
  has_many :permissors, :through => :permissions, :as => :permissible, :class_name => self.by.to_s.camelize

  send :include, InstanceMethods
end