Module: Databasedotcom::Convenience::ClassMethods

Defined in:
lib/databasedotcom/convenience/base.rb

Instance Method Summary collapse

Instance Method Details

#const_missing(sym) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/databasedotcom/convenience/base.rb', line 38

def const_missing(sym)
  if sobject_types.include?(sym.to_s)
    dbdc_client.materialize(sym.to_s)
  else
    super
  end
end

#dbdc_clientObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/databasedotcom/convenience/base.rb', line 13

def dbdc_client
  unless @dbdc_client
    config = YAML.load_file(File.join(File.join Dir.pwd, 'config', 'databasedotcom.yml'))
    config = config.has_key?(::Databasedotcom::Convenience.env) ? config[::Databasedotcom::Convenience.env] : config
    username = config["username"]
    password = config["password"]
    @dbdc_client = Databasedotcom::Client.new(config)
    @dbdc_client.authenticate(:username => username, :password => password)
  end

  @dbdc_client
end

#dbdc_client=(client) ⇒ Object



26
27
28
# File 'lib/databasedotcom/convenience/base.rb', line 26

def dbdc_client=(client)
  @dbdc_client = client
end

#sobject_typesObject



30
31
32
33
34
35
36
# File 'lib/databasedotcom/convenience/base.rb', line 30

def sobject_types
  unless @sobject_types
    @sobject_types = dbdc_client.list_sobjects
  end

  @sobject_types
end