123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- class Sessions::Backend::Collections < Sessions::Backend::Base
- def initialize(user, asset_lookup, client, client_id, ttl = 10)
- @user = user
- @client = client
- @client_id = client_id
- @ttl = ttl
- @asset_lookup = asset_lookup
- @backends = backend
- end
- def push
- results = []
- @backends.each { |backend|
- #puts "B: #{backend.inspect}"
- result = backend.push
- #puts "R: #{result.inspect}"
- if result
- results.push result
- end
- }
- results
- end
- def backend
- # auto population collections
- backends = []
- # load collections to deliver from external files
- dir = File.expand_path('../../../../', __FILE__)
- files = Dir.glob("#{dir}/lib/sessions/backend/collections/*.rb")
- files.each { |file|
- file.gsub!("#{dir}/lib/", '')
- file.gsub!(/\.rb$/, '')
- next if file.classify == 'Sessions::Backend::Collections::Base'
- #puts "LOAD #{file.classify}---"
- #next if file == ''
- backend = file.classify.constantize.new(@user, @asset_lookup, @client, @client_id, @ttl)
- if backend
- backends.push backend
- end
- }
- backends
- end
- end
|