Class: SolidObjects::ComponentRegistration

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_objects/component_registration.rb,
sig/generated/lib/solid_objects/component_registration.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, instance_id:, revision:, refresh_path:, token:) ⇒ ComponentRegistration

Returns a new instance of ComponentRegistration.

RBS:

  • (reference: Reference, component_name: String, component_key: String | Integer?, dependencies: Array[String], locals: Hash[String, untyped], refresh_method: String, instance_id: Integer, revision: Integer, refresh_path: String, token: String) -> void

Parameters:

  • reference: (Reference)
  • component_name: (String)
  • component_key: (String, Integer, nil)
  • dependencies: (Array[String])
  • locals: (Hash[String, untyped])
  • refresh_method: (String)
  • instance_id: (Integer)
  • revision: (Integer)
  • refresh_path: (String)
  • token: (String)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/solid_objects/component_registration.rb', line 30

def initialize(
  reference:,
  component_name:,
  component_key:,
  dependencies:,
  locals:,
  refresh_method:,
  instance_id:,
  revision:,
  refresh_path:,
  token:
)
  @reference = reference
  @component_name = component_name
  @component_key = component_key
  @dependencies = dependencies.freeze
  @locals = Serialization.readonly_copy(locals)
  @refresh_method = refresh_method
  @instance_id = instance_id
  @revision = revision
  @refresh_path = refresh_path
  @token = token
end

Instance Attribute Details

#component_keyObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def component_key
  @component_key
end

#component_nameObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def component_name
  @component_name
end

#dependenciesObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def dependencies
  @dependencies
end

#instance_idObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def instance_id
  @instance_id
end

#localsObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def locals
  @locals
end

#referenceObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def reference
  @reference
end

#refresh_methodObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def refresh_method
  @refresh_method
end

#refresh_pathObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def refresh_path
  @refresh_path
end

#revisionObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def revision
  @revision
end

#tokenObject (readonly)

RBS:

  • @reference: Reference

  • @component_name: String

  • @component_key: String | Integer?

  • @dependencies: Array[String]

  • @locals: Hash[String, untyped]

  • @refresh_method: String

  • @instance_id: Integer

  • @revision: Integer

  • @refresh_path: String

  • @token: String

Returns:

  • (Object)


18
19
20
# File 'lib/solid_objects/component_registration.rb', line 18

def token
  @token
end

Class Method Details

.from_token(token) ⇒ ComponentRegistration

RBS:

  • (String) -> ComponentRegistration

Parameters:

  • (String)

Returns:



81
82
83
84
85
86
# File 'lib/solid_objects/component_registration.rb', line 81

def from_token(token)
  payload = ComponentToken.verify(token)
  build(payload, token:)
rescue UnknownActorType, UnknownComponentDependency => error
  raise InvalidComponentToken, error.message
end

.issue(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, snapshot:, refresh_path:) ⇒ ComponentRegistration

RBS:

  • (reference: Reference, component_name: String, component_key: untyped, dependencies: Array[String], locals: Hash[untyped, untyped], refresh_method: String | Symbol, snapshot: ActorSnapshot, refresh_path: String) -> ComponentRegistration

Parameters:

  • reference: (Reference)
  • component_name: (String)
  • component_key: (Object)
  • dependencies: (Array[String])
  • locals: (Hash[untyped, untyped])
  • refresh_method: (String, Symbol)
  • snapshot: (ActorSnapshot)
  • refresh_path: (String)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/solid_objects/component_registration.rb', line 56

def issue(
  reference:,
  component_name:,
  component_key:,
  dependencies:,
  locals:,
  refresh_method:,
  snapshot:,
  refresh_path:
)
  token = ComponentToken.generate(
    reference:,
    component_name:,
    component_key:,
    dependencies:,
    locals:,
    refresh_method:,
    instance_id: snapshot.instance_id,
    revision: snapshot.revision,
    refresh_path:
  )
  build(ComponentToken.verify(token), token:)
end

Instance Method Details

#authorization_argumentsHash[String, untyped]

RBS:

  • () -> Hash[String, untyped]

Returns:

  • (Hash[String, untyped])


146
147
148
149
150
# File 'lib/solid_objects/component_registration.rb', line 146

def authorization_arguments
  return locals unless component_key

  locals.merge("component_key" => component_key).freeze
end

#dom_idString

RBS:

  • () -> String

Returns:

  • (String)


132
133
134
135
136
137
138
# File 'lib/solid_objects/component_registration.rb', line 132

def dom_id
  DomIdentity.component(
    reference,
    component_name,
    key: component_key
  )
end

#morph?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


141
142
143
# File 'lib/solid_objects/component_registration.rb', line 141

def morph?
  refresh_method == "morph"
end

#refresh_url(instance_id, revision) ⇒ String

RBS:

  • (Integer, Integer) -> String

Parameters:

  • (Integer)
  • (Integer)

Returns:

  • (String)


153
154
155
156
157
158
159
160
# File 'lib/solid_objects/component_registration.rb', line 153

def refresh_url(instance_id, revision)
  query = URI.encode_www_form(
    token:,
    instance_id:,
    revision:
  )
  "#{refresh_path}?#{query}"
end

#revision_keyArray[Integer]

RBS:

  • () -> Array[Integer]

Returns:

  • (Array[Integer])


127
128
129
# File 'lib/solid_objects/component_registration.rb', line 127

def revision_key
  [ instance_id, revision ]
end