Last active
December 11, 2015 02:18
-
-
Save amardaxini/4529114 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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