Sha256: f3a76dd8be23e92d18ccf176e458022e2ec26da5c6bd40aebb0c17a28e186073

Contents?: true

Size: 905 Bytes

Versions: 3

Compression:

Stored size: 905 Bytes

Contents

$:.unshift(File.join("..", "lib"))

require 'rubygems'

require 'rack'
require 'hoth'
require 'hoth/providers/rack_provider'
require 'business_objects'

Hoth.init!

class IncrementStatisticsImpl
  def self.execute(statistic_objects, event)
    puts "** EXECUTING IncrementStatisticsImpl"
    puts "   statistic_objects: #{statistic_objects.inspect}"
    puts "   events: #{event.inspect}"
  end
end

class StatisticOfCarsImpl
  def self.execute(ids)
    puts "** EXECUTING StatisticOfCarsImpl"
    puts "   ids: #{ids.inspect}"
    
    return ids.inject([]) do |data, id|
      data << StatisticData.new(
        :events       => [Event.new(:name => "viewed", :count => rand(666))],
        :original_id => id
      )
    end
  end
end

app = lambda {|env| [200, {'Content-Type' => 'application/json'}, ["body"]]}

rack_thread = Thread.new { run Hoth::Providers::RackProvider.new(app) }
rack_thread.join

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hoth-0.4.2 example/rack_service_provider.ru
hoth-0.4.1 example/rack_service_provider.ru
hoth-0.4.0 example/rack_service_provider.ru