lib/dionysus/security/password_salt.rb in dionysus-0.3.0 vs lib/dionysus/security/password_salt.rb in dionysus-0.3.1

- old
+ new

@@ -75,22 +75,14 @@ # You may always pass in an options hash as the last argument. # [length] Length of salt to be generated. # Default: 8 def initialize( *args ) options = args.extract_options! - if args[0].nil? or args[0] == :new or args[0].is_a?(String) - self.string = args[0] || :new - end - if args[0].is_a?(Symbol) and args[0] != :new - self.placement = args[0] - elsif args[1].is_a?(Symbol) - self.placement = args[1] - else - self.placement = DEFAULT_PLACEMENT - end + self.string = args.detect { |val| val.is_a?(String) or val == :new } + self.placement = args.detect { |val| PLACEMENTS.include?(val) } || DEFAULT_PLACEMENT - if self.string == :new + if self.string == :new or self.string.nil? self.string = self.class.generate(options[:length] || DEFAULT_LENGTH) end end ##