lib/cfoundry/v2/model.rb in cfoundry-0.3.50 vs lib/cfoundry/v2/model.rb in cfoundry-0.3.51
- old
+ new
@@ -40,14 +40,15 @@
def defaults
@defaults ||= {}
end
def attribute(name, type, opts = {})
- default = opts[:default] || nil
+ default = opts[:default]
- has_default = opts.key?(:default)
- defaults[name] = default if has_default
+ if has_default = opts.key?(:default)
+ defaults[name] = default
+ end
define_method(name) {
manifest[:entity][name] || default
}
@@ -78,14 +79,11 @@
end
define_method(name) {
if @manifest && @manifest[:entity].key?(name)
@client.send(:"make_#{obj}", @manifest[:entity][name])
- else
- @client.send(
- :"#{obj}_from",
- send("#{name}_url"),
- opts[:depth] || 1)
+ elsif url = send("#{name}_url")
+ @client.send(:"#{obj}_from", url, opts[:depth] || 1)
end
}
define_method(:"#{name}_url") {
manifest[:entity][:"#{name}_url"]