Module: ObjectBouncer::Doorman

Defined in:
lib/objectbouncer/base.rb,
lib/objectbouncer/class_methods.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/objectbouncer/base.rb', line 38

def self.included(klass)
  klass.extend ClassMethods
  klass.overwrite_initialize
  klass.instance_eval do
    def method_added(name)
      overwrite_initialize if name == :initialize
    end
  end
end

Instance Method Details

#apply_policiesObject



28
29
30
31
32
# File 'lib/objectbouncer/base.rb', line 28

def apply_policies
  policies.keys.each do |method|
    self.class.protect_method!(method)
  end
end

#current_userObject



24
25
26
# File 'lib/objectbouncer/base.rb', line 24

def current_user
  @current_user ||= self.class.current_user
end

#current_user=(user) ⇒ Object



20
21
22
# File 'lib/objectbouncer/base.rb', line 20

def current_user=(user)
  @current_user = user
end

#policiesObject



34
35
36
# File 'lib/objectbouncer/base.rb', line 34

def policies
  @policies || self.class.instance_policies
end

#with(user) ⇒ Object



16
17
18
# File 'lib/objectbouncer/base.rb', line 16

def with(user)
  self
end