Class: NetFlix::Credentials
Constant Summary
collapse
- CONFIG_FILENAME =
File.join( File.expand_path('config'), 'netflix_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
20
21
22
|
# File 'lib/net_flix/credentials.rb', line 20
def config_file_exists?
File.exist? CONFIG_FILENAME
end
|
.from_file ⇒ Object
16
17
18
|
# File 'lib/net_flix/credentials.rb', line 16
def from_file
new(config_file_exists? ? YAML.load(File.open(CONFIG_FILENAME)) : {})
end
|
Instance Method Details
#to_file! ⇒ Object
26
27
28
29
30
|
# File 'lib/net_flix/credentials.rb', line 26
def to_file!
credentials_store = File.new(CONFIG_FILENAME, 'w')
credentials_store.puts(self.to_yaml)
credentials_store.close
end
|
#to_yaml ⇒ Object
32
33
34
|
# File 'lib/net_flix/credentials.rb', line 32
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
|