Sha256: 69dc120d5cc42b51210d0e2484c698b8e8e00d8acab9eddc34943abc3514e44e

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

require "extface/engine"
require "extface/routes"
require "extface/mapping"
require "extface/extfaceable"
module Extface
  mattr_accessor :redis_connection_string
  
  mattr_reader :mappings
  @@mappings = ActiveSupport::OrderedHash.new
  
  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 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

1 entries across 1 versions & 1 rubygems

Version Path
extface-0.0.3 lib/extface.rb