Class: DearInventory::Config

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dear_inventory/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



20
21
22
23
# File 'lib/dear_inventory/config.rb', line 20

def initialize
  @logger = Logger.new(STDOUT)
  @logger.level = Logger::WARN
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



11
12
13
# File 'lib/dear_inventory/config.rb', line 11

def 
  @account_id
end

#keyObject

Returns the value of attribute key.



14
15
16
# File 'lib/dear_inventory/config.rb', line 14

def key
  @key
end

#loggerObject

Returns the value of attribute logger.



17
18
19
# File 'lib/dear_inventory/config.rb', line 17

def logger
  @logger
end

Instance Method Details

#environmentObject



26
27
28
# File 'lib/dear_inventory/config.rb', line 26

def environment
  DearInventory::Environment
end

#environment=(value) ⇒ Object



31
32
33
# File 'lib/dear_inventory/config.rb', line 31

def environment=(value)
  DearInventory::Environment.set(value)
end

#require(param) ⇒ Object



36
37
38
39
40
41
# File 'lib/dear_inventory/config.rb', line 36

def require(param)
  value = public_send(param)
  return value unless value.nil? || value.empty?

  require_error(param)
end

#require_parameter(param) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/dear_inventory/config.rb', line 44

def require_parameter(param)
  require(param)
rescue ArgumentError => e
  message = e.message + "\n" \
    "Alternatively, you can pass dynamic values with your request " \
    "parameters"
  raise ArgumentError, message
end