Module: Zuul::ActiveRecord::ContextMethods

Defined in:
lib/zuul/active_record.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



340
341
342
343
# File 'lib/zuul/active_record.rb', line 340

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



346
347
348
# File 'lib/zuul/active_record.rb', line 346

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



351
352
353
354
355
# File 'lib/zuul/active_record.rb', line 351

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