lib/cfoundry/v2/model.rb in cfoundry-0.3.24 vs lib/cfoundry/v2/model.rb in cfoundry-0.3.25
- old
+ new
@@ -61,11 +61,13 @@
}
end
def to_one(name, opts = {})
obj = opts[:as] || name
- kls = obj.to_s.capitalize
+ kls = obj.to_s.capitalize.gsub(/(.)_(.)/) do
+ $1 + $2.upcase
+ end
define_method(name) {
if @manifest && @manifest[:entity].key?(name)
@client.send(:"make_#{obj}", @manifest[:entity][name])
else
@@ -90,13 +92,16 @@
}
end
def to_many(plural, opts = {})
singular = plural.to_s.sub(/s$/, "").to_sym
- kls = singular.to_s.capitalize
object = opts[:as] || singular
plural_object = :"#{object}s"
+
+ kls = object.to_s.capitalize.gsub(/(.)_(.)/) do
+ $1 + $2.upcase
+ end
define_method(plural) { |*args|
depth, query = args
if @manifest && @manifest[:entity].key?(plural) && !depth