Module: Roleful::InstanceMethods

Defined in:
lib/roleful/inclusion.rb

Instance Method Summary collapse

Instance Method Details

#with_role(*tmp_roles) ⇒ Object Also known as: with_roles

Gives an object temporary roles for the duration of the block.



14
15
16
17
18
19
20
# File 'lib/roleful/inclusion.rb', line 14

def with_role(*tmp_roles)
  old_role = method(:role)
  meta_def(:role) { tmp_roles }
  result = yield
  meta_eval { define_method(:role, old_role) }
  result
end