lib/mitake/model/attributes.rb in mitake-0.1.1 vs lib/mitake/model/attributes.rb in mitake-0.1.2

- old
+ new

@@ -16,10 +16,14 @@ # @param attributes [Hash] the attributes to assignment # # @since 0.1.0 def assign_attributes(attributes = {}) attributes.each do |key, value| - send("#{key}=", value) + next unless self.class.attribute_names.include?(key.to_s) + next send("#{key}=", value) if respond_to?("#{key}=") + + type = self.class.attributes[key.to_s] + instance_variable_set("@#{key}", self.class.cast(value, type)) end end end end end