Class: NetFlix::Credentials
Constant Summary
collapse
- @@config_file_name =
File.join( File.dirname(__FILE__), '..', '..', 'credentials.yml')
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Valuable
#attributes, attributes, create_accessor_for, create_setter_for, #deep_duplicate_of, defaults, has_collection, has_value, #initialize
Constructor Details
This class inherits a constructor from Valuable
Class Method Details
.config_file_exists? ⇒ Boolean
24
25
26
|
# File 'lib/net_flix/credentials.rb', line 24
def config_file_exists?
File.exist? @@config_file_name
end
|
.config_file_name=(file_name) ⇒ Object
16
17
18
|
# File 'lib/net_flix/credentials.rb', line 16
def config_file_name= file_name
@@config_file_name = file_name
end
|
.from_file ⇒ Object
20
21
22
|
# File 'lib/net_flix/credentials.rb', line 20
def from_file
new(config_file_exists? ? YAML.load(File.open(@@config_file_name)) : {})
end
|
Instance Method Details
#to_file! ⇒ Object
30
31
32
33
34
|
# File 'lib/net_flix/credentials.rb', line 30
def to_file!
credentials_store = File.new(@@config_file_name, 'w')
credentials_store.puts(self.to_yaml)
credentials_store.close
end
|
#to_yaml ⇒ Object
36
37
38
|
# File 'lib/net_flix/credentials.rb', line 36
def to_yaml
attributes.to_yaml
end
|
#valid? ⇒ Boolean
10
11
12
|
# File 'lib/net_flix/credentials.rb', line 10
def valid?
(key && secret) != nil
end
|