lib/cistern/client.rb in cistern-2.2.7 vs lib/cistern/client.rb in cistern-2.3.0
- old
+ new
@@ -1,13 +1,13 @@
module Cistern::Client
module Collections
def collections
- service.collections
+ cistern.collections
end
def requests
- service.requests
+ cistern.requests
end
end
# custom include
def self.with(options = {})
@@ -40,27 +40,50 @@
singular_class = options[:singular] || 'Singular'
interface = options[:interface] || :class
interface_callback = (:class == interface) ? :inherited : :included
+ if interface == :class
+ Cistern.deprecation(
+ %q{class' interface is deprecated. Use `include Cistern::Client.with(interface: :module). See https://github.com/lanej/cistern#custom-architecture},
+ caller[2],
+ )
+ end
+
unless klass.name
- fail ArgumentError, "can't turn anonymous class into a Cistern service"
+ fail ArgumentError, "can't turn anonymous class into a Cistern cistern"
end
klass.class_eval <<-EOS, __FILE__, __LINE__
module Collections
include ::Cistern::Client::Collections
- def service
+ def cistern
+ Cistern.deprecation(
+ '#cistern is deprecated. Please use #cistern',
+ caller[0]
+ )
#{klass.name}
end
+
+ def cistern
+ #{klass.name}
+ end
end
- def self.service
+ def self.cistern
+ Cistern.deprecation(
+ '#cistern is deprecated. Please use #cistern',
+ caller[0]
+ )
#{klass.name}
end
+ def self.cistern
+ #{klass.name}
+ end
+
class Real
def initialize(options={})
end
end
@@ -69,65 +92,97 @@
end
end
#{interface} #{model_class}
def self.#{interface_callback}(klass)
- service.models << klass
+ cistern.models << klass
klass.send(:include, ::Cistern::Model)
super
end
- def self.service
+ def self.cistern
+ Cistern.deprecation(
+ '#cistern is deprecated. Please use #cistern',
+ caller[0]
+ )
#{klass.name}
end
+
+ def self.cistern
+ #{klass.name}
+ end
end
#{interface} #{singular_class}
def self.#{interface_callback}(klass)
- service.singularities << klass
+ cistern.singularities << klass
klass.send(:include, ::Cistern::Singular)
super
end
def self.service
+ Cistern.deprecation(
+ '#service is deprecated. Please use #cistern',
+ caller[0]
+ )
#{klass.name}
end
+
+ def self.cistern
+ #{klass.name}
+ end
end
#{interface} #{collection_class}
include ::Cistern::Collection
def self.#{interface_callback}(klass)
klass.send(:extend, Cistern::Attributes::ClassMethods)
klass.send(:extend, Cistern::Collection::ClassMethods)
klass.send(:include, Cistern::Attributes::InstanceMethods)
- service.collections << klass
+ cistern.collections << klass
super
end
def self.service
+ Cistern.deprecation(
+ '#service is deprecated. Please use #cistern',
+ caller[0]
+ )
#{klass.name}
end
+
+ def self.cistern
+ #{klass.name}
+ end
end
#{interface} #{request_class}
include ::Cistern::Request
def self.service
+ Cistern.deprecation(
+ '#service is deprecated. Please use #cistern',
+ caller[0]
+ )
#{klass.name}
end
+ def self.cistern
+ #{klass.name}
+ end
+
def self.#{interface_callback}(klass)
klass.extend(::Cistern::Request::ClassMethods)
- service.requests << klass
+ cistern.requests << klass
super
end
def _mock(*args)
@@ -217,34 +272,34 @@
def setup
return true if @_setup
requests.each do |klass|
- name = klass.service_method ||
+ name = klass.cistern_method ||
Cistern::String.camelize(Cistern::String.demodulize(klass.name))
- Cistern::Request.service_request(self, klass, name)
+ Cistern::Request.cistern_request(self, klass, name)
end
collections.each do |klass|
- name = klass.service_method ||
+ name = klass.cistern_method ||
Cistern::String.underscore(klass.name.gsub("#{self.name}::", '').gsub('::', ''))
- Cistern::Collection.service_collection(self, klass, name)
+ Cistern::Collection.cistern_collection(self, klass, name)
end
models.each do |klass|
- name = klass.service_method ||
+ name = klass.cistern_method ||
Cistern::String.underscore(klass.name.gsub("#{self.name}::", '').gsub('::', ''))
- Cistern::Model.service_model(self, klass, name)
+ Cistern::Model.cistern_model(self, klass, name)
end
singularities.each do |klass|
- name = klass.service_method ||
+ name = klass.cistern_method ||
Cistern::String.underscore(klass.name.gsub("#{self.name}::", '').gsub('::', ''))
- Cistern::Singular.service_singular(self, klass, name)
+ Cistern::Singular.cistern_singular(self, klass, name)
end
@_setup = true
end