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_name ⇒ Object readonly
- #dependencies ⇒ Object readonly
- #instance_id ⇒ Object readonly
- #reference ⇒ Object readonly
- #refresh_path ⇒ Object readonly
- #revision ⇒ Object readonly
- #token ⇒ Object readonly
Class Method Summary collapse
- .from_token(token) ⇒ ComponentRegistration
- .issue(reference:, component_name:, dependencies:, snapshot:, refresh_path:) ⇒ ComponentRegistration
Instance Method Summary collapse
-
#initialize(reference:, component_name:, dependencies:, instance_id:, revision:, refresh_path:, token:) ⇒ ComponentRegistration
constructor
A new instance of ComponentRegistration.
- #refresh_url(instance_id, revision) ⇒ String
- #revision_key ⇒ Array[Integer]
Constructor Details
#initialize(reference:, component_name:, dependencies:, instance_id:, revision:, refresh_path:, token:) ⇒ ComponentRegistration
Returns a new instance of ComponentRegistration.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/solid_objects/component_registration.rb', line 24 def initialize( reference:, component_name:, dependencies:, instance_id:, revision:, refresh_path:, token: ) @reference = reference @component_name = component_name @dependencies = dependencies.freeze @instance_id = instance_id @revision = revision @refresh_path = refresh_path @token = token end |
Instance Attribute Details
#component_name ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def component_name @component_name end |
#dependencies ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def dependencies @dependencies end |
#instance_id ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def instance_id @instance_id end |
#reference ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def reference @reference end |
#refresh_path ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def refresh_path @refresh_path end |
#revision ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def revision @revision end |
#token ⇒ Object (readonly)
15 16 17 |
# File 'lib/solid_objects/component_registration.rb', line 15 def token @token end |
Class Method Details
.from_token(token) ⇒ ComponentRegistration
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 65 def from_token(token) payload = ComponentToken.verify(token) reference = Reference.new( actor_type: payload.fetch("actor_type"), actor_id: payload.fetch("actor_id") ) dependencies = payload.fetch("dependencies") validate_dependencies!(reference, dependencies) new( reference:, component_name: payload.fetch("component_name"), dependencies:, instance_id: payload.fetch("instance_id"), revision: payload.fetch("revision"), refresh_path: payload.fetch("refresh_path"), token: ) rescue UnknownActorType, UnknownComponentDependency => error raise InvalidComponentToken, error. end |
.issue(reference:, component_name:, dependencies:, snapshot:, refresh_path:) ⇒ ComponentRegistration
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/solid_objects/component_registration.rb', line 44 def issue(reference:, component_name:, dependencies:, snapshot:, refresh_path:) token = ComponentToken.generate( reference:, component_name:, dependencies:, instance_id: snapshot.instance_id, revision: snapshot.revision, refresh_path: ) new( reference:, component_name:, dependencies:, instance_id: snapshot.instance_id, revision: snapshot.revision, refresh_path:, token: ) end |
Instance Method Details
#refresh_url(instance_id, revision) ⇒ String
108 109 110 111 112 113 114 115 |
# File 'lib/solid_objects/component_registration.rb', line 108 def refresh_url(instance_id, revision) query = URI.encode_www_form( token:, instance_id:, revision: ) "#{refresh_path}?#{query}" end |
#revision_key ⇒ Array[Integer]
103 104 105 |
# File 'lib/solid_objects/component_registration.rb', line 103 def revision_key [ instance_id, revision ] end |