Module: Canable::Role::ClassMethods

Defined in:
lib/canable/role.rb

Overview

These are applied to the actual Role module ‘instance’ that includes this (Canable::Role) module

Defined Under Namespace

Modules: RoleEnabledCanInstanceMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_default_responseObject

Each role has a default query response, found in this variable



12
13
14
# File 'lib/canable/role.rb', line 12

def _default_response
  @_default_response
end

Instance Method Details

#default_response(val) ⇒ Object


Role building DSL




40
41
42
# File 'lib/canable/role.rb', line 40

def default_response(val)
  self._default_response = val
end

#extended(base) ⇒ Object

Called when an Actor decides its role and extends itself (an instance) with a Role implementation Creates the default instance methods for an Actor and persists the can_action? response default down



24
25
26
27
28
# File 'lib/canable/role.rb', line 24

def extended(base)
  base.extend(RoleEnabledCanInstanceMethods)
  this_role = self # can't use self inside the instance eval
  base.instance_eval { @_canable_role = this_role }
end

#included(base) ⇒ Object

Called when another Role imeplementation module tries to inherit an existing Role implementation Notice this method isn’t self.included, this method becomes self.included on the module including this (Canable::Role) module This is nesscary to emulate inhertance of the default response and any other variables in the future



18
19
20
# File 'lib/canable/role.rb', line 18

def included(base)
  base._default_response = self._default_response
end