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
- #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:) ⇒ ComponentRegistration
Instance Method Summary collapse
- #authorization_arguments ⇒ Hash[String, untyped]
- #dom_id ⇒ String
-
#initialize(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, instance_id:, revision:, refresh_path:, token:) ⇒ 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:) ⇒ ComponentRegistration
Returns a new instance of ComponentRegistration.
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_key ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def component_key @component_key end |
#component_name ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def component_name @component_name end |
#dependencies ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def dependencies @dependencies end |
#instance_id ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def instance_id @instance_id end |
#locals ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def locals @locals end |
#reference ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def reference @reference end |
#refresh_method ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def refresh_method @refresh_method end |
#refresh_path ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def refresh_path @refresh_path end |
#revision ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def revision @revision end |
#token ⇒ Object (readonly)
18 19 20 |
# File 'lib/solid_objects/component_registration.rb', line 18 def token @token end |
Class Method Details
.from_token(token) ⇒ ComponentRegistration
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. end |
.issue(reference:, component_name:, component_key:, dependencies:, locals:, refresh_method:, snapshot:, refresh_path:) ⇒ ComponentRegistration
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_arguments ⇒ Hash[String, untyped]
146 147 148 149 150 |
# File 'lib/solid_objects/component_registration.rb', line 146 def return locals unless component_key locals.merge("component_key" => component_key).freeze end |
#dom_id ⇒ 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
141 142 143 |
# File 'lib/solid_objects/component_registration.rb', line 141 def morph? refresh_method == "morph" end |
#refresh_url(instance_id, revision) ⇒ 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_key ⇒ Array[Integer]
127 128 129 |
# File 'lib/solid_objects/component_registration.rb', line 127 def revision_key [ instance_id, revision ] end |