lib/util/utils.rb in nubefact-0.0.6 vs lib/util/utils.rb in nubefact-0.0.7
- old
+ new
@@ -23,18 +23,18 @@
end
private
def set_default_data
self.class::DEFAULT_DATA.each do |field, value|
- value = value.call if value.kind_of? Proc
+ next if send(field)
+
+ value = value.call(self) if value.kind_of? Proc
send "#{field}=", value
end
end
def load_data_from_param(data_hash)
- set_default_data
-
data_hash.each do|key, value|
if self.class.const_defined?('AUTO_CALCULATED_FIELDS') \
&& self.class::AUTO_CALCULATED_FIELDS.include?(key)
warn("field #{key} will be calculated automatically, you don't need to pass it.")
end
@@ -43,7 +43,9 @@
send "#{key}=", value
rescue NoMethodError => e
raise NubeFact::InvalidField.new "Invalid Field: #{key}"
end
end
+
+ set_default_data
end
end
\ No newline at end of file