lib/cistern/collection.rb in cistern-2.2.7 vs lib/cistern/collection.rb in cistern-2.3.0
- old
+ new
@@ -3,28 +3,53 @@
:compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!,
:shuffle!, :slice!, :sort!, :sort_by!, :delete_if,
:keep_if, :pop, :shift, :delete_at, :compact
].to_set # :nodoc:
- def self.service_collection(service, klass, name)
- service.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
+ def self.cistern_collection(cistern, klass, name)
+ cistern.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
def #{name}(attributes={})
- #{klass.name}.new(attributes.merge(service: self))
+ #{klass.name}.new(attributes.merge(cistern: self))
end
EOS
end
- attr_accessor :records, :loaded, :service
+ attr_accessor :records, :loaded, :cistern
+ def service=(service)
+ Cistern.deprecation(
+ '#service= is deprecated. Please use #cistern=',
+ caller[0]
+ )
+ @cistern = service
+ end
+
+ def service
+ Cistern.deprecation(
+ '#service is deprecated. Please use #cistern',
+ caller[0]
+ )
+ @cistern
+ end
+
module ClassMethods
def model(new_model = nil)
@_model ||= new_model
end
+ # @deprecated Use {#cistern_method} instead
def service_method(name = nil)
- @_service_method ||= name
+ Cistern.deprecation(
+ '#service_method is deprecated. Please use #cistern_method',
+ caller[0]
+ )
+ @_cistern_method ||= name
end
+
+ def cistern_method(name = nil)
+ @_cistern_method ||= name
+ end
end
alias_method :build, :initialize
def initialize(attributes = {})
@@ -78,10 +103,10 @@
fail(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
end
model.new(
{
collection: self,
- service: service
+ cistern: cistern,
}.merge(attributes)
)
end
def reload