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.4.5 lib/extface.rb
extface-0.4.4b lib/extface.rb
extface-0.4.4a lib/extface.rb
extface-0.4.4 lib/extface.rb
extface-0.4.3g lib/extface.rb
extface-0.4.3f lib/extface.rb
extface-0.4.3e lib/extface.rb
extface-0.4.3d lib/extface.rb
extface-0.4.3c lib/extface.rb
extface-0.4.3b lib/extface.rb
extface-0.4.3a lib/extface.rb
extface-0.4.2a lib/extface.rb
extface-0.4.2 lib/extface.rb
extface-0.4.1b lib/extface.rb
extface-0.4.1a lib/extface.rb
extface-0.4.0 lib/extface.rb
extface-0.3.0c lib/extface.rb
extface-0.3.0b lib/extface.rb
extface-0.3.0a lib/extface.rb
extface-0.3.0 lib/extface.rb