Module: AppleDEPClient::Configuration

Included in:
AppleDEPClient
Defined in:
lib/apple_dep_client/configuration.rb

Constant Summary collapse

DEP_CONFIG =
{
  private_key: nil,         # MDM Server's private key for decrypting token files
  consumer_key: nil,        # Server Token information
  consumer_secret: nil,
  access_token: nil,
  access_secret: nil,
  access_token_expiry: nil,
  apple_dep_server: "https://mdmenrollment.apple.com", # Domain that Apple's DEP servers are at
  user_agent: "CellabusMDM",
}

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *_args, &_block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/apple_dep_client/configuration.rb', line 22

def method_missing(m, *_args, &_block)
  if DEP_CONFIG.keys.include? m.to_sym
    get_value(m)
  else
    raise NoMethodError, "Unknown method #{m}"
  end
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



40
41
42
# File 'lib/apple_dep_client/configuration.rb', line 40

def configure
  yield self
end

#get_default_value(key) ⇒ Object



36
37
38
# File 'lib/apple_dep_client/configuration.rb', line 36

def get_default_value(key)
  DEP_CONFIG[key.to_sym]
end

#get_value(m) ⇒ Object



30
31
32
33
34
# File 'lib/apple_dep_client/configuration.rb', line 30

def get_value(m)
  value = instance_variable_get("@#{m}")
  value = get_default_value(m) if value.nil?
  (value.is_a? Proc) ? value.call : value
end