Module: SimpleRoles::Many::Persistence
- Defined in:
- lib/simple_roles/many/persistence.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/simple_roles/many/persistence.rb', line 5 def included base base.class_eval %{ has_many :user_roles has_many :roles, :through => :user_roles } end |
Instance Method Details
#roles ⇒ Object
13 14 15 |
# File 'lib/simple_roles/many/persistence.rb', line 13 def roles super.map(&:name).map(&:to_sym) end |
#roles=(*rolez) ⇒ Object
17 18 19 20 21 |
# File 'lib/simple_roles/many/persistence.rb', line 17 def roles= *rolez rolez = rolez.flatten.map(&:to_sym) super retrieve_roles(rolez) end |