Class: Synaptic4r::Client
- Inherits:
-
Object
- Object
- Synaptic4r::Client
- Includes:
- Utils
- Defined in:
- lib/synaptic4r/client.rb
Overview
Class Attribute Summary collapse
-
.config_file ⇒ Object
readonly
Returns the value of attribute config_file.
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ Client
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
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 account = args[:account] if account aconfig = config_by_account(account) raise ArgumentError, "Account '#{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_file ⇒ Object (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
#credentials ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….….….
20 21 22 |
# File 'lib/synaptic4r/client.rb', line 20 def credentials @credentials end |