Module: Zuul::ActiveRecord::ContextAccessors

Defined in:
lib/zuul/active_record/context_accessors.rb

Overview

These are included in roles & permissions objects and assigned roles & permissions objects to provide easy access to the context for that object.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/zuul/active_record/context_accessors.rb', line 6

def self.included(base)
  base.send :attr_accessible, :context if ::Zuul.should_whitelist?
end

Instance Method Details

#contextObject

Return a Zuul::Context object representing the context for the role



11
12
13
# File 'lib/zuul/active_record/context_accessors.rb', line 11

def context
  Zuul::Context.new context_type, context_id
end

#context=(context) ⇒ Object

Parse a context into an Zuul::Context and set the type and id



16
17
18
19
20
# File 'lib/zuul/active_record/context_accessors.rb', line 16

def context=(context)
  context = Zuul::Context.parse(context)
  self.context_type = context.klass
  self.context_id = context.id
end