Module: Platanus::Canned::ControllerExt

Defined in:
lib/platanus/canned.rb

Overview

Controller extension, include this in the the base application controller and use the barracks_setup method to define the profiles definition object and the user profile provider block.

Defined Under Namespace

Modules: ClassMethods Classes: ActionWrapper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#brk_tagObject

Returns the value of attribute brk_tag.



19
20
21
# File 'lib/platanus/canned.rb', line 19

def brk_tag
  @brk_tag
end

Class Method Details

.included(klass) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/platanus/canned.rb', line 21

def self.included(klass)
  class << klass
    # Excluded actions are defined in per class basis
    attr_accessor :brk_excluded
  end
  protected
  # Definition and role provider are shared with subclasses
  klass.cattr_accessor :brk_definition
  klass.cattr_accessor :brk_provider
  public
  klass.extend ClassMethods
end

Instance Method Details

#can?(_action, _action_feat) ⇒ Boolean

Test if an action can be executed using the currently loaded roles.

Returns:

  • (Boolean)


65
66
67
68
69
70
71
72
73
74
# File 'lib/platanus/canned.rb', line 65

def can?(_action, _action_feat)
  wrapper = ActionWrapper.new(self, _action, _action_feat)
  begin
    provider = if brk_provider.is_a? Symbol then self.method(brk_provider) else brk_provider end
    wrapper.instance_eval &provider
    return false
  rescue Interrupt
    return (if wrapper.tag.nil? then true else wrapper.tag end)
  end
end