lib/cistern/model.rb in cistern-0.11.2.pre2 vs lib/cistern/model.rb in cistern-0.11.2
- old
+ new
@@ -1,15 +1,11 @@
-module Cistern::Model
+class Cistern::Model
+ extend Cistern::Attributes::ClassMethods
include Cistern::Attributes::InstanceMethods
- def self.included(klass)
- klass.send(:extend, Cistern::Attributes::ClassMethods)
- klass.send(:include, Cistern::Attributes::InstanceMethods)
- end
+ attr_accessor :collection, :connection
- attr_accessor :collection, :service
-
def inspect
if Cistern.formatter
Cistern.formatter.call(self)
else
"#<#{self.class} #{self.identity}"
@@ -54,17 +50,17 @@
else
super
end
end
- def wait_for(timeout = self.service_class.timeout, interval = self.service_class.poll_interval, &block)
- service_class.wait_for(timeout, interval) { reload && block.call(self) }
+ def service
+ self.connection ? self.connection.class : Cistern
end
- def wait_for!(timeout = self.service_class.timeout, interval = self.service_class.poll_interval, &block)
- service_class.wait_for!(timeout, interval) { reload && block.call(self) }
+ def wait_for(timeout = self.service.timeout, interval = self.service.poll_interval, &block)
+ service.wait_for(timeout, interval) { reload && block.call(self) }
end
- def service_class
- self.service ? self.service.class : Cistern
+ def wait_for!(timeout = self.service.timeout, interval = self.service.poll_interval, &block)
+ service.wait_for!(timeout, interval) { reload && block.call(self) }
end
end