Skip to content

Instantly share code, notes, and snippets.

@amardaxini
Last active December 11, 2015 02:18
Show Gist options
  • Save amardaxini/4529114 to your computer and use it in GitHub Desktop.
Save amardaxini/4529114 to your computer and use it in GitHub Desktop.
module Ups
class Configuration
attr_accessor :user_id,:password,:licence
def initialzie
user_id,password,licence=nil,nil,nil
end
end
class << self
attr_accessor :configuration
end
def self.configure
self.configuration = Configuration.new
yield(configuration) if block_given?
end
end
Ups.configure do |config|
config.user_id = "amar"
config.password = "password"
config.licence = "licencenu"
end
Ups.configure.user_id = "amardaxini"
Ups.configuration
# MOst of time we need single instance of object of configuration
require 'rubygems'
require 'singleton'
module Ups
class Configuration
include Singleton
attr_accessor :user_id,:password,:licence
def initialzie
user_id,password,licence=nil,nil,nil
end
end
class << self
attr_accessor :configuration
end
def self.configure
self.configuration = Configuration.instance
yield(configuration) if block_given?
end
end
Ups.configure do |config|
config.user_id = "amar"
config.password = "password"
config.licence = "licencenu"
end
Ups.configure.user_id = "amardaxini"
Ups.configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment