spec/fixtures/models/user.rb in cantango-0.9.3.2 vs spec/fixtures/models/user.rb in cantango-0.9.4

- old
+ new

@@ -26,9 +26,27 @@ def role @role || '' end + # This hash should be recalculated anytime the permissions collection changes + # + + # after_update :recalculate_permissions_hash + + def permissions_hash + @permissions_hash = permissions.hash + end + def permissions @permissions ||= [] + end + + # allows implementation specific to ORM, fx using #all on some datastores such as Mongoid etc. + alias_method :all_permissions, :permissions + + protected + + def recalculate_permissions_hash + @permissions_hash = nil if self.permissions_changed? end end