lib/cistern/singular.rb in cistern-2.3.0 vs lib/cistern/singular.rb in cistern-2.4.0
- old
+ new
@@ -1,44 +1,34 @@
module Cistern::Singular
+ include Cistern::Model
+
def self.cistern_singular(cistern, klass, name)
cistern.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
def #{name}(attributes={})
- #{klass.name}.new(attributes.merge(cistern: self))
+ #{klass.name}.new(attributes.merge(cistern: self))
end
EOS
end
def self.included(klass)
+ super
+
klass.send(:extend, Cistern::Attributes::ClassMethods)
klass.send(:include, Cistern::Attributes::InstanceMethods)
klass.send(:extend, Cistern::Model::ClassMethods)
end
- attr_accessor :cistern
-
- def service
- Cistern.deprecation(
- '#service is deprecated. Please use #cistern',
- caller[0]
- )
- @cistern
+ def collection
+ self
end
- def inspect
- Cistern.formatter.call(self)
+ def get
+ raise NotImplementedError
end
- def initialize(options)
- merge_attributes(options)
- reload
- end
-
def reload
- new_attributes = fetch_attributes
-
- merge_attributes(new_attributes) if new_attributes
+ get
+ self
end
- def fetch_attributes
- fail NotImplementedError
- end
+ alias load reload
end