class MovieMasher::Service
abstraction layer for initing, upload, download, queue services
Constants
- SERVICES_DIRECTORY
Attributes
__configuration[RW]
__instances[RW]
__services[RW]
Public Class Methods
configure_services(config)
click to toggle source
# File lib/service.rb, line 10 def configure_services(config) Service.__configuration = config end
downloader(type)
click to toggle source
# File lib/service.rb, line 14 def downloader(type) instance(:download, type) end
initer(type)
click to toggle source
# File lib/service.rb, line 18 def initer(type) instance(:init, type) end
instance(kind, type)
click to toggle source
# File lib/service.rb, line 22 def instance(kind, type) Service.__instances[kind] ||= {} if Service.__instances[kind][type].nil? s = __create_service(type, kind) Service.__instances[kind][type] = if s && s.configure(Service.__configuration) s else false end end Service.__instances[kind][type] end
queues()
click to toggle source
# File lib/service.rb, line 36 def queues array = [] services(:queue).each do |hash| type = hash[:name] s = instance(:queue, type) array << s if s end array end
services(kind = nil)
click to toggle source
# File lib/service.rb, line 46 def services(kind = nil) kind_nil = kind.nil? kinds = kind_nil ? %i[queue upload download init] : [kind.to_sym] kinds.each do |kind_sym| Service.__services[kind_sym] ||= __scan_for_services(kind_sym) end kind_nil ? Service.__services : Service.__services[kind.to_sym] end
uploader(type)
click to toggle source
# File lib/service.rb, line 55 def uploader(type) instance(:upload, type) end
Public Instance Methods
configuration()
click to toggle source
# File lib/service.rb, line 96 def configuration Service.__configuration end
configure(*)
click to toggle source
# File lib/service.rb, line 100 def configure(*) true end