module Surrounded::Context
Attributes
default_role_type[W]
Public Class Methods
extended(base)
click to toggle source
# File lib/surrounded/context.rb, line 21 def self.extended(base) base.class_eval { extend RoleBuilders, Initializing, Forwarding, NameCollisionDetector @triggers = Set.new include InstanceMethods trigger_mod = Module.new const_set('TriggerMethods', trigger_mod) include trigger_mod extend TriggerControls } end
Private Class Methods
default_role_type()
click to toggle source
Set the default type of implementation for role methods for all contexts.
# File lib/surrounded/context.rb, line 40 def self.default_role_type @default_role_type ||= :module end
Private Instance Methods
default_role_type()
click to toggle source
# File lib/surrounded/context.rb, line 48 def default_role_type @default_role_type ||= Surrounded::Context.default_role_type end
default_role_type=(type)
click to toggle source
Set the default type of implementation for role method for an individual context.
# File lib/surrounded/context.rb, line 53 def default_role_type=(type) @default_role_type = type end
east_oriented_triggers()
click to toggle source
Automatically return the context object from trigger methods.
# File lib/surrounded/context.rb, line 64 def east_oriented_triggers; self.extend(::Surrounded::EastOriented); end
private_attr_reader(*method_names)
click to toggle source
Create attr_reader for the named methods and make them private
# File lib/surrounded/context.rb, line 82 def private_attr_reader(*method_names) attr_reader(*method_names) private(*method_names) end
private_const_set(name, const)
click to toggle source
Set a named constant and make it private
# File lib/surrounded/context.rb, line 73 def private_const_set(name, const) unless role_const_defined?(name) const = const_set(name, const) private_constant name.to_sym end const end
protect_triggers()
click to toggle source
Provide the ability to create access control methods for your triggers.
# File lib/surrounded/context.rb, line 58 def protect_triggers; self.extend(::Surrounded::AccessControl); end
role_const(name)
click to toggle source
Conditional const_get for a named role behavior
# File lib/surrounded/context.rb, line 88 def role_const(name) if role_const_defined?(name) const_get(name) end end
role_const_defined?(name)
click to toggle source
role_mapper_class(mapper: RoleMap, base: ::Triad)
click to toggle source
Allow alternative implementations for the role map This requires that the specified mapper klass have an initializer method called 'from_base' which accepts a class name used to initialize the base object
# File lib/surrounded/context.rb, line 98 def role_mapper_class(mapper: RoleMap, base: ::Triad) @role_mapper_class ||= mapper.from_base(base) end
shortcut_triggers()
click to toggle source
Automatically create class methods for each trigger method.
# File lib/surrounded/context.rb, line 61 def shortcut_triggers; self.extend(::Surrounded::Shortcuts); end