Sha256: 0b8ade7e1c5f38b0809c31ae0154fceabe910cd4b934243a6fe34174da4bab41

Contents?: true

Size: 806 Bytes

Versions: 8

Compression:

Stored size: 806 Bytes

Contents

module DesignShell
	class KeyChain

		def initialize(aNamespace)
			@keychain = OSXKeychain.new
			@namespace = aNamespace
		end

		def [](aKey)
			get(aKey)
		end

		def []=(aKey,aValue)
			set(aKey,aValue)
		end

		def set(aKey,aValue=nil,aPrefix='')
			if (aKey.is_a?(String) || aKey.is_a?(Symbol))
				@keychain[@namespace,aPrefix.to_s+aKey.to_s] = aValue
			elsif aKey.is_a?(Hash)
				prefix = aValue || aPrefix
				aKey.each {|k,v| set(k,v,prefix)}
			end
		end

		def get(aKey,aPrefix=nil,aKeepPrefix=false)
			if (aKey.is_a?(Array))
				result = {}
				aKey.each do |k|
					storeKey = (aKeepPrefix ? aPrefix.to_s+k.to_s : k.to_s)
					v = get(k.to_s,aPrefix)
					result[storeKey] = v
				end
				return result
			else
				return @keychain[@namespace,aPrefix.to_s+aKey.to_s]
			end
		end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
designshell-0.0.8 lib/designshell/key_chain.rb
designshell-0.0.7 lib/designshell/key_chain.rb
designshell-0.0.6 lib/designshell/key_chain.rb
designshell-0.0.5 lib/designshell/key_chain.rb
designshell-0.0.4 lib/designshell/key_chain.rb
designshell-0.0.3 lib/designshell/key_chain.rb
designshell-0.0.2 lib/designshell/key_chain.rb
designshell-0.0.1 lib/designshell/key_chain.rb