Skip to content
Browse files

Sanction::Role::Definition behave like a collection using Enumerable …

…mixin
  • Loading branch information...
1 parent fafb837 commit c9d0ff9b321918c32f70ebcd9b00e6e29752a25a @joegoggins joegoggins committed with Feb 11, 2010
Showing with 15 additions and 0 deletions.
  1. +15 −0 app/models/sanction/role/definition.rb
View
15 app/models/sanction/role/definition.rb
@@ -186,6 +186,21 @@ def describe
"#{prefix} can have #{name.to_s.titleize}#{suffix}"
end
+ def self.first
+ self.all_roles.first
+ end
+
+ def self.last
+ self.all_roles.last
+ end
+
+ # Make the class behave like a sensible collection!
+ extend Enumerable
+ def self.each
+ self.all_roles.each do |x|
+ yield x
+ end
+ end
#--------------------------------------------------#
# Private API #

0 comments on commit c9d0ff9

Please sign in to comment.
Something went wrong with that request. Please try again.