lib/cfoundry/v2/model.rb in cfoundry-0.4.16 vs lib/cfoundry/v2/model.rb in cfoundry-0.4.17
- old
+ new
@@ -3,12 +3,25 @@
require "cfoundry/v2/model_magic"
module CFoundry::V2
class Model
+ @@objects = {}
+
extend ModelMagic
+ class << self
+ def objects
+ @@objects
+ end
+
+ def inherited(klass)
+ @@objects[klass.object_name] = klass
+ super
+ end
+ end
+
attr_accessor :guid, :cache, :changes
def initialize(guid, client, manifest = nil, partial = false)
@guid = guid
@client = client
@@ -35,9 +48,13 @@
"\#<#{self.class.name} '#@guid'>"
end
def object_name
@object_name ||= self.class.object_name
+ end
+
+ def plural_object_name
+ @plural_object_name ||= self.class.plural_object_name
end
def invalidate!
@manifest = nil
@partial = false