Permalink
Browse files

Refactored `easy_roles` method to remove duplication.

  • Loading branch information...
jeriko committed Nov 26, 2011
1 parent 4351290 commit bb5c7fe687a76643cc6e1bcfaee46b53bf35028f
Showing with 3 additions and 7 deletions.
  1. +3 −7 lib/easy_roles.rb
View
@@ -15,18 +15,14 @@ module EasyRoles
end
module ClassMethods
- def easy_roles(name, options = {})
- options[:method] ||= :serialize
-
+ def easy_roles(name, options = {})
begin
raise NameError unless ALLOWED_METHODS.include? options[:method]
-
- "EasyRoles::#{options[:method].to_s.camelize}".constantize.new(self, name, options)
rescue NameError
puts "[Easy Roles] Storage method does not exist reverting to Serialize"
-
- EasyRoles::Serialize.new(self, name, options)
+ options[:method] = :serialize
end
+ "EasyRoles::#{options[:method].to_s.camelize}".constantize.new(self, name, options)
end
end

0 comments on commit bb5c7fe

Please sign in to comment.