Sha256: 4712e42c8aec0e6a99a0d22c049613ebab32ae13dc9e025d152a42e609ba30dd

Contents?: true

Size: 1.12 KB

Versions: 71

Compression:

Stored size: 1.12 KB

Contents

require "extface/engine"
require "extface/routes"
require "extface/mapping"
require "extface/extfaceable"
require "redis-namespace"
module Extface
  RAW_DRIVER = "Raw Communication Devices"
  PRINT_DRIVER = "Print Devices"
  FISCAL_DRIVER = "Fiscal Printers & Cash Registers"
  REPORT_DRIVER = "CDR Loggers, Report Devices"
    
  mattr_accessor :redis_connection_string
  
  mattr_reader :mappings
  @@mappings = ActiveSupport::OrderedHash.new
  
  mattr_reader :device_timeout
  @@device_timeout = 10
  
  class << self
    def setup
      yield self
    end

    def add_mapping(resource, options)
      mapping = Extface::Mapping.new(resource, options)
      @@mappings[mapping.name] = mapping
    end
    
    def redis_block
      r = redis_instance
      begin
        yield Redis::Namespace.new(:extface, :redis => r)
      ensure
        r.quit
      end
    end
    
    private
      def redis_instance
        if @@redis_connection_string
          uri = URI.parse(@@redis_connection_string)
          Redis.new(host: uri.host, port: uri.port, password: uri.password)
        else
          Redis.new
        end
      end
  end 
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
extface-0.5.4a lib/extface.rb
extface-0.5.4 lib/extface.rb
extface-0.5.3 lib/extface.rb
extface-0.5.2 lib/extface.rb
extface-0.5.1 lib/extface.rb
extface-0.5.0 lib/extface.rb
extface-0.4.9 lib/extface.rb
extface-0.4.8 lib/extface.rb
extface-0.4.7 lib/extface.rb
extface-0.4.6k lib/extface.rb
extface-0.4.6i lib/extface.rb
extface-0.4.6h lib/extface.rb
extface-0.4.6g lib/extface.rb
extface-0.4.6f lib/extface.rb
extface-0.4.6e lib/extface.rb
extface-0.4.6d lib/extface.rb
extface-0.4.6c lib/extface.rb
extface-0.4.6b lib/extface.rb
extface-0.4.6a lib/extface.rb
extface-0.4.6 lib/extface.rb