require 'rubygems' require 'rest_client' require 'json' module Maskedmail def self.configure if ENV['MASKEDMAIL_URL'] @resource = RestClient::Resource.new(ENV['MASKEDMAIL_URL']) else @development = true end end def self.all return [dummy_mask] if @development request = @resource.get JSON.parse(request) end def self.create(email_address) return dummy_mask if @development request = @resource.post(:email_address => email_address) JSON.parse(request) end def self.get(id) return dummy_mask if @development request = @resource[id].get JSON.parse(request) end def self.update(id, email_address) return dummy_mask if @development request = @resource[id].put(:email_address => email_address) JSON.parse(request) end def self.delete(id) return dummy_mask if @development request = @resource[id].delete JSON.parse(request) end def dummy_mask {:id => 1, :destination => 'dummy@maskedmail.net', :mask => 'user-1234@maskedmail.net'} end end