Sha256: a7bf3fe94b3332ddaaa0e156226213d61a69e0d1ae5c746dd723ff9091fb51ed

Contents?: true

Size: 781 Bytes

Versions: 3

Compression:

Stored size: 781 Bytes

Contents

require 'httparty'

module CrowdRest
  include HTTParty

  autoload :Session, 'crowd_rest/session'
  autoload :User,    'crowd_rest/user'
  
  headers 'Content-type' => 'text/xml'
  
  class << self
    attr_reader :app_name, :app_pass
  end
  
  def self.config
    yield(self)
  end
  
  def self.crowd_url=(url)
    base_uri("#{url}/crowd/rest/usermanagement/1")
  end
  
  def self.app_name=(app_name)
    @app_name = app_name
    do_basic_auth if credentials_set?
  end
  
  def self.app_pass=(app_pass)
    @app_pass = app_pass
    do_basic_auth if credentials_set?
  end
  
  private
  
  def self.do_basic_auth
    self.basic_auth(@app_name, @app_pass)
  end
  
  def self.credentials_set?
    @app_name && !@app_name.empty? &&
    @app_pass && !@app_pass.empty?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crowd_rest-0.1.1 lib/crowd_rest.rb
crowd_rest-0.1.0 lib/crowd_rest.rb
crowd_rest-0.0.2 lib/crowd_rest.rb