lib/uencode.rb in uencode-3.0.0 vs lib/uencode.rb in uencode-3.1.0
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (c) 2011, uEncode, Cassio Marques
+# Copyright (c) 2011, uEncode, Cássio Marques
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'singleton'
@@ -16,11 +16,20 @@
end
end
module AttrSetting
def set_attributes(options)
- self.class.const_get("ATTRIBUTES").each { |attr| instance_variable_set(:"@#{attr}", options[attr.to_sym] || options[attr.to_s]) }
- end
+# self.class.const_get("ATTRIBUTES").each { |attr| instance_variable_set(:"@#{attr}", options[attr.to_sym] || options[attr.to_s]) }
+# options.each do |key, value|
+ options.each_pair { |key, value|
+ if self.class.const_get("ATTRIBUTES").include?(key)
+ instance_variable_set(:"@#{key}", value)
+ else
+ self.send("#{key}=", value)
+ end
+ }
+
+ end
def initialize(options)
set_attributes options
end