Class: Role::PermissionsAttributeCoder

Inherits:
Object
  • Object
show all
Defined in:
app/models/role.rb

Overview

Custom coder for the permissions attribute that should be an array of symbols. Rails 3 uses Psych which can be unbelievably slow on some platforms (eg. mingw32).

Class Method Summary collapse

Class Method Details

.dump(value) ⇒ Object


27
28
29
# File 'app/models/role.rb', line 27

def self.dump(value)
  YAML.dump(value)
end

.load(str) ⇒ Object


23
24
25
# File 'app/models/role.rb', line 23

def self.load(str)
  str.to_s.scan(/:([a-z0-9_]+)/).flatten.map(&:to_sym)
end