Class: Platanus::Canned::ControllerExt::ActionWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/platanus/canned.rb

Overview

Wraps a controller instance and provides the profile testing enviroment used by the role provider function.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_owner, _action, _actions_feats) ⇒ ActionWrapper

Loads the testing enviroment.



41
42
43
44
45
46
# File 'lib/platanus/canned.rb', line 41

def initialize(_owner, _action, _actions_feats)
  @owner = _owner
  @action = _action
  @feats = _actions_feats
  @tag = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(_method, *_args, &_block) ⇒ Object

Since we need to provide with all of controller functionality to provider, then proxy al failed method calls to it.



59
60
61
# File 'lib/platanus/canned.rb', line 59

def method_missing(_method, *_args, &_block)
  @owner.send(_method, *_args, &_block)
end

Instance Attribute Details

#tagObject (readonly)

Returns the value of attribute tag.



38
39
40
# File 'lib/platanus/canned.rb', line 38

def tag
  @tag
end

Instance Method Details

#test(_profile, _user_feats, _tag = nil) ⇒ Object

Test if a profile can execute the current action, raises a Interrupt exception if conditions are met.



50
51
52
53
54
55
# File 'lib/platanus/canned.rb', line 50

def test(_profile, _user_feats, _tag=nil)
  if @owner.class.brk_definition.can?(_profile, @action, @feats, _user_feats)
    @tag = _tag
    raise Interrupt
  end
end