Module: Reactor::Permission::Base

Defined in:
lib/reactor/permission.rb

Instance Method Summary collapse

Instance Method Details

#edit!(*args) ⇒ Object

Wraps around Reactor::Persistence::Base#edit! and ensures that current user has required permissions to edit the object

Raises:



50
51
52
53
# File 'lib/reactor/permission.rb', line 50

def edit!(*args)
  ensure_permission_granted(:edit)
  super
end

#permissionObject

See Also:

  • [PermissionProxy]


19
20
21
# File 'lib/reactor/permission.rb', line 19

def permission
  @permission ||= PermissionProxy.new(self)
end

#release!(*args) ⇒ Object

Wraps around Reactor::Persistence::Base#release! and ensures that current user has required permissions to release the object

Raises:



26
27
28
29
# File 'lib/reactor/permission.rb', line 26

def release!(*args)
  ensure_permission_granted(:release)
  super
end

#resolve_refs!Object

Wraps around Reactor::Persistence::Base#resolve_refs! and ensures that current user has required permissions to call resolve refs on the object

Raises:



84
85
86
87
# File 'lib/reactor/permission.rb', line 84

def resolve_refs!
  ensure_permission_granted(:write)
  super
end

#revert!(*args) ⇒ Object

Wraps around Reactor::Persistence::Base#revert! and ensures that current user has required permissions to revert the object

Raises:



42
43
44
45
# File 'lib/reactor/permission.rb', line 42

def revert!(*args)
  ensure_permission_granted(:revert)
  super
end

#saveObject

Wraps around ActiveRecord::Persistence#save and ensures that current user has required permissions to save the object

Raises:



58
59
60
61
62
63
64
65
66
67
# File 'lib/reactor/permission.rb', line 58

def save
  if persisted?
    ensure_permission_granted(:write)
  else
    ensure_create_permission_granted(parent_obj_id)
  end
  super
rescue Reactor::NotPermitted
  false
end

#save!Object

Wraps around ActiveRecord::Persistence#save! and ensures that current user has required permissions to save the object

Raises:



72
73
74
75
76
77
78
79
# File 'lib/reactor/permission.rb', line 72

def save!
  if persisted?
    ensure_permission_granted(:write)
  else
    ensure_create_permission_granted(parent_obj_id)
  end
  super
end

#take!(*args) ⇒ Object

Wraps around Reactor::Persistence::Base#take! and ensures that current user has required permissions to take the object

Raises:



34
35
36
37
# File 'lib/reactor/permission.rb', line 34

def take!(*args)
  ensure_permission_granted(:take)
  super
end