Class: SolidObjects::ComponentRegistration
- Inherits:
-
Object
- Object
- SolidObjects::ComponentRegistration
- Defined in:
- lib/solid_objects/component_registration.rb,
sig/generated/lib/solid_objects/component_registration.rbs
Instance Attribute Summary collapse
- #batch ⇒ Object readonly
- #component_key ⇒ Object readonly
- #component_name ⇒ Object readonly
- #dependencies ⇒ Object readonly
- #instance_id ⇒ Object readonly
- #locals ⇒ Object readonly
- #reference ⇒ Object readonly
- #refresh_method ⇒ Object readonly
- #refresh_path ⇒ Object readonly
- #revision ⇒ Object readonly
- #token ⇒ Object readonly
Class Method Summary collapse
- .from_token(token) ⇒ ComponentRegistration
- .issue(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, snapshot:, refresh_path:, batch: nil) ⇒ ComponentRegistration
Instance Method Summary collapse
- #authorization_arguments ⇒ Hash[String, untyped]
- #batch_refresh_url(registrations:, instance_id:, revision:) ⇒ String
- #dom_id ⇒ String
-
#initialize(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, instance_id:, revision:, refresh_path:, token:, batch: nil) ⇒ ComponentRegistration
constructor
A new instance of ComponentRegistration.
- #morph? ⇒ Boolean
- #refresh_url(instance_id, revision) ⇒ String
- #revision_key ⇒ Array[Integer]
Constructor Details
#initialize(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, instance_id:, revision:, refresh_path:, token:, batch: nil) ⇒ ComponentRegistration
Returns a new instance of ComponentRegistration.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/solid_objects/component_registration.rb', line 32 def initialize( reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, instance_id:, revision:, refresh_path:, token:, batch: nil ) @reference = reference @batch = batch @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
#batch ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def batch @batch end |
#component_key ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def component_key @component_key end |
#component_name ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def component_name @component_name end |
#dependencies ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def dependencies @dependencies end |
#instance_id ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def instance_id @instance_id end |
#locals ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def locals @locals end |
#reference ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def reference @reference end |
#refresh_method ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def refresh_method @refresh_method end |
#refresh_path ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def refresh_path @refresh_path end |
#revision ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def revision @revision end |
#token ⇒ Object (readonly)
19 20 21 |
# File 'lib/solid_objects/component_registration.rb', line 19 def token @token end |
Class Method Details
.from_token(token) ⇒ ComponentRegistration
87 88 89 90 91 92 |
# File 'lib/solid_objects/component_registration.rb', line 87 def from_token(token) payload = ComponentToken.verify(token) build(payload, token:) rescue UnknownActorType, UnknownComponentDependency => error raise InvalidComponentToken, error. end |
.issue(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, snapshot:, refresh_path:, batch: nil) ⇒ ComponentRegistration
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/solid_objects/component_registration.rb', line 60 def issue( reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, snapshot:, refresh_path:, batch: nil ) token = ComponentToken.generate( reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, batch:, instance_id: snapshot.instance_id, revision: snapshot.revision, refresh_path: ) build(ComponentToken.verify(token), token:) end |
Instance Method Details
#authorization_arguments ⇒ Hash[String, untyped]
153 154 155 156 157 |
# File 'lib/solid_objects/component_registration.rb', line 153 def return locals unless component_key locals.merge("component_key" => component_key).freeze end |
#batch_refresh_url(registrations:, instance_id:, revision:) ⇒ String
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/solid_objects/component_registration.rb', line 160 def batch_refresh_url(registrations:, instance_id:, revision:) query = URI.encode_www_form( [ [ "instance_id", instance_id ], [ "revision", revision ], *registrations.map { |registration| [ "tokens[]", registration.token ] } ] ) "#{refresh_path}/batch?#{query}" end |
#dom_id ⇒ String
139 140 141 142 143 144 145 |
# File 'lib/solid_objects/component_registration.rb', line 139 def dom_id DomIdentity.component( reference, component_name, key: component_key ) end |
#morph? ⇒ Boolean
148 149 150 |
# File 'lib/solid_objects/component_registration.rb', line 148 def morph? refresh_method == "morph" end |
#refresh_url(instance_id, revision) ⇒ String
172 173 174 175 176 177 178 179 |
# File 'lib/solid_objects/component_registration.rb', line 172 def refresh_url(instance_id, revision) query = URI.encode_www_form( token:, instance_id:, revision: ) "#{refresh_path}?#{query}" end |
#revision_key ⇒ Array[Integer]
134 135 136 |
# File 'lib/solid_objects/component_registration.rb', line 134 def revision_key [ instance_id, revision ] end |