Class: Roempro::Config
Class Method Summary collapse
-
.load_from_hash(params = {}) ⇒ Object
Load the default configuration into Roempro::Config.
Methods inherited from Class
cattr_accessor, cattr_reader, cattr_writer
Class Method Details
.load_from_hash(params = {}) ⇒ Object
Load the default configuration into Roempro::Config.
Once the default configuration loaded into this object, all new Roempro’s components will use those informations to configure themself. Unless a specific configuration is provide at creation.
Parameters
- Hash
- :url
-
Define the path to the desired Oempro API
- :username
-
The username to use for login
- :password
-
The user’s password
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/roempro/config.rb', line 22 def self.load_from_hash(params={}) params = Hash[params.map {|k,v| [k.to_sym,v] }] @@username = params[:username].to_s if params[:username] @@password = params[:password].to_s if params[:password] @@url = if params[:url] if uri = URI.parse(params[:url]) and uri.instance_of? URI::HTTPS raise ArgumentError, "Roempro::Request doesn't support SSL yet" end if uri.instance_of? URI::Generic "http://" + params[:url].to_s elsif uri.kind_of? URI::HTTP params[:url].to_s end end return self if @@url or @@username or @@password rescue URI::Error, ArgumentError => puts end |