Class: Synaptic4r::Client

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/synaptic4r/client.rb

Overview


Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#create_timestamp, #read_file, #symbolize, #unary_args_given?

Constructor Details

#initialize(args = nil) ⇒ Client

.….….….….….….….….….….….….….….….….….….….….….….….….….….



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/synaptic4r/client.rb', line 23

def initialize(args = nil)
  config_params = %w(key site subtenant uid)
  if args
     = args[:account]
    if 
      aconfig = ()
      raise ArgumentError, "Account '#{}' not found in #{ENV['HOME']}/.synaptic4r" unless aconfig
      args.update(symbolize(aconfig))
    end
  else
    if config.kind_of?(Hash)
      args = symbolize(config)
    elsif config.kind_of?(Array)
      cfg = config.first
      args = symbolize(cfg)
    else
      raise ArgumentError, "#{ENV['HOME']}/.synaptic4r not formatted properly"
    end
  end
  unary_args_given?(symbolize(config_params), args.keys)
  @credentials= {:subtenant => args[:subtenant], :uid => args[:uid], :key => args[:key], :site => args[:site]}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



47
48
49
50
51
52
53
# File 'lib/synaptic4r/client.rb', line 47

def method_missing(meth, *args, &blk)
  if StorageRequest.has_rest_method?(meth)
    StorageRequest.new(credentials).execute(meth, *args, &blk)
  else
    super
  end
end

Class Attribute Details

.config_fileObject (readonly)

Returns the value of attribute config_file.



16
17
18
# File 'lib/synaptic4r/client.rb', line 16

def config_file
  @config_file
end

Instance Attribute Details

#credentialsObject (readonly)

.….….….….….….….….….….….….….….….….….….….….….….….….….….



20
21
22
# File 'lib/synaptic4r/client.rb', line 20

def credentials
  @credentials
end