Class: Toggl::Jobcan::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/toggl/jobcan/credentials.rb

Overview

Jobcan credentials manager

Constant Summary collapse

ATTRS =
%i[email password].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Credentials

Returns a new instance of Credentials.



14
15
16
17
18
# File 'lib/toggl/jobcan/credentials.rb', line 14

def initialize(args)
  attr_set(args) if args.key?(:email)
  c = self.class.load_config(args[:path])
  attr_set(c)
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



9
10
11
# File 'lib/toggl/jobcan/credentials.rb', line 9

def email
  @email
end

#passwordObject

Returns the value of attribute password.



10
11
12
# File 'lib/toggl/jobcan/credentials.rb', line 10

def password
  @password
end

Class Method Details

.load_config(path) ⇒ Object



21
22
23
# File 'lib/toggl/jobcan/credentials.rb', line 21

def load_config(path)
  YAML.safe_load(File.open(path).read).transform_keys(&:to_sym)
end