Sha256: 425451a4c8a3cfc35b7bfd369eb158452ea3bd2dc3d4cb8e0e65aa6cc269c310

Contents?: true

Size: 733 Bytes

Versions: 23

Compression:

Stored size: 733 Bytes

Contents

module Rasti
  class App
    class ServiceFactory

      class << self

        def service(name, service_class=nil)
          services[name] = service_class || Consty.get(Inflecto.camelize(name), self)

          define_method name do
            cache[name] ||= begin
              adapter_class = Consty.get(settings[name][:adapter], self.class.services[name])
              self.class.services[name].new adapter_class.new(settings[name][:options])
            end
          end
        end

        def services
          @services ||= {}
        end

      end

      def initialize(settings)
        @settings = settings
        @cache = {}
      end

      private

      attr_reader :settings, :cache
      
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rasti-app-2.2.4 lib/rasti/app/service_factory.rb
rasti-app-2.2.3 lib/rasti/app/service_factory.rb
rasti-app-2.2.2 lib/rasti/app/service_factory.rb
rasti-app-2.2.1 lib/rasti/app/service_factory.rb
rasti-app-2.2.0 lib/rasti/app/service_factory.rb
rasti-app-2.1.1 lib/rasti/app/service_factory.rb
rasti-app-2.1.0 lib/rasti/app/service_factory.rb
rasti-app-2.0.0 lib/rasti/app/service_factory.rb
rasti-app-1.1.0 lib/rasti/app/service_factory.rb
rasti-app-1.0.0 lib/rasti/app/service_factory.rb
rasti-app-0.1.2 lib/rasti/app/service_factory.rb
rasti-app-0.1.1 lib/rasti/app/service_factory.rb
rasti-app-0.1.0 lib/rasti/app/service_factory.rb
rasti-app-0.0.10 lib/rasti/app/service_factory.rb
rasti-app-0.0.9 lib/rasti/app/service_factory.rb
rasti-app-0.0.8 lib/rasti/app/service_factory.rb
rasti-app-0.0.7 lib/rasti/app/service_factory.rb
rasti-app-0.0.6 lib/rasti/app/service_factory.rb
rasti-app-0.0.5 lib/rasti/app/service_factory.rb
rasti-app-0.0.4 lib/rasti/app/service_factory.rb