Class: RETS4R::ListingService

Inherits:
Object
  • Object
show all
Defined in:
lib/rets4r/listing_service.rb

Constant Summary collapse

@@configurations =
nil
@@env =
'development'

Class Method Summary collapse

Class Method Details

.configurationsObject

The configuration hash for every environment that has one.



17
18
19
# File 'lib/rets4r/listing_service.rb', line 17

def self.configurations
  @@configurations
end

.configurations=(obj) ⇒ Object

Set the collection of configuration hashes, one for each environment.

If you want to set configurations by hand:

RETS4R::ListingService.configurations = {
  :development => { 'url' => 'http://www.dis.com:6103/rets/login' }
  :test => { 'url' => 'http://demo.crt.realtors.org:6103/rets/login' }
}

But you probably just want to do something like this

RETS4R::ListingService.configurations = YAML.load_file('config/listing_service.yml')


31
32
33
# File 'lib/rets4r/listing_service.rb', line 31

def self.configurations=(obj)
  @@configurations = obj
end

.connection(spec = nil) ⇒ Object

Connection configuration for the specified environment, or the current environment if none is given.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rets4r/listing_service.rb', line 52

def self.connection(spec = nil)
  case spec
    when nil
      connection(RETS4R::ListingService.env)
    when Symbol, String
      if configuration = configurations[spec.to_s]
        configuration.keys.each do |key|
          configuration[(key.to_sym rescue key) || key] = configuration.delete(key)
        end
        configuration
      else
        raise ArgumentError, "#{spec} listing service is not configured"
      end
    else
      raise ArgumentError, "#{spec} listing service is not configured"
  end
end

.envObject

Current environment used to access the appropriate configuration from ::configurations. Defaults to ‘development’.



46
47
48
# File 'lib/rets4r/listing_service.rb', line 46

def self.env
  @@env
end

.env=(obj) ⇒ Object

Set the current environment to use. Defaults to ‘development’.



40
41
42
# File 'lib/rets4r/listing_service.rb', line 40

def self.env=(obj)
  @@env = obj
end