Method: AppIdentity::App#initialize

Defined in:
lib/app_identity/app.rb

#initialize(input) ⇒ App

Constructs an AppIdentity::App from a provided object or zero-arity callable that returns an initialization object. These values should be treated as immutable objects.

The object must respond to #id, #secret, #version, and #config or have indexable keys (via #[]) of id, secret, version, and config as either Symbol or String values. That is, the id should be retrievable in one of the following ways:

“‘ruby input.id input input “`

If the input parameter is a callable, it will be called with no parameters to produce an input object.

The AppIdentity::App is frozen on creation.

“‘ruby AppIdentity::App.new(1, secret: “secret”, version: 1)

AppIdentity::App.new(->() { 1, secret: “secret”, version: 1 }) “‘

If the provided input is already an App and is not #verified, the existing app will be returned instead of creating a new application.



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/app_identity/app.rb', line 118

def initialize(input)
  input = input.call if input.respond_to?(:call)

  @id = get(input, :id)
  @secret = fwrap(get(input, :secret).dup)
  @version = get(input, :version)
  @config = get(input, :config)
  @source = input
  @verified = false

  validate!
  freeze
end