Class: GoogleDirectory::Config::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/google-directory/config.rb

Overview

def []( attribute ) return nil unless PUBLIC_ATTRS.include?(attribute) instance_variable_get(“@#attribute”) end

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Builder

Returns a new instance of Builder.



63
64
65
66
67
# File 'lib/google-directory/config.rb', line 63

def initialize(&block)
	@config = @current_config = Config.new
	@config.instance_variable_set('@scopes', { })
	instance_eval(&block)
end

Instance Method Details

#admin_email(admin_email) ⇒ Object



81
82
83
# File 'lib/google-directory/config.rb', line 81

def admin_email( admin_email )
	@current_config.instance_variable_set('@admin_email', admin_email)
end

#application_name(application_name) ⇒ Object



97
98
99
# File 'lib/google-directory/config.rb', line 97

def application_name( application_name )
	@current_config.instance_variable_set('@application_name', application_name)
end

#application_version(application_version) ⇒ Object



101
102
103
# File 'lib/google-directory/config.rb', line 101

def application_version( application_version )
	@current_config.instance_variable_set('@application_version', application_version)
end

#buildObject



69
70
71
# File 'lib/google-directory/config.rb', line 69

def build
	@config
end

#issuer(issuer) ⇒ Object



93
94
95
# File 'lib/google-directory/config.rb', line 93

def issuer( issuer )
	@current_config.instance_variable_set('@issuer', issuer)
end

#key_file(key_file) ⇒ Object



85
86
87
# File 'lib/google-directory/config.rb', line 85

def key_file( key_file )
	@current_config.instance_variable_set('@key_file', key_file)
end

#key_passphrase(key_passphrase) ⇒ Object



89
90
91
# File 'lib/google-directory/config.rb', line 89

def key_passphrase( key_passphrase )
	@current_config.instance_variable_set('@key_passphrase', key_passphrase)
end

#scope(scope_name, &block) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/google-directory/config.rb', line 105

def scope( scope_name, &block )
	scopes = @config.instance_variable_get('@scopes')
	scopes[scope_name] = @current_config = Config.new(scope_name)

	@current_config.instance_variable_set('@token_store', @token_store)

	instance_eval(&block)
	@current_config = @config
end

#use_yaml(yaml_file) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/google-directory/config.rb', line 73

def use_yaml( yaml_file )
	
	File.exist?(yaml_file) || FileUtils.touch(yaml_file)
	@token_store = YamlTokenStore.new( yaml_file )
	@current_config.instance_variable_set('@token_store', @token_store)

end