Class: Webhookdb::Replicator::Descriptor
- Inherits:
-
TypedStruct
- Object
- TypedStruct
- Webhookdb::Replicator::Descriptor
- Defined in:
- lib/webhookdb/replicator.rb
Overview
Statically describe a replicator.
Instance Attribute Summary collapse
-
#api_docs_url ⇒ Object
readonly
URL pointing to the provider (not-WebhookDB) docs for this integration.
-
#ctor ⇒ Object
Method invoked with the
Webhookdb::ServiceIntegration
, and should return a new instance of the integration. -
#dependency_descriptor ⇒ Object
The descriptor for the service this one depends on (the parent).
-
#description ⇒ Object
readonly
Markdown description of this replicator.
-
#documentation_url ⇒ Object
readonly
If this integration has specific documentation, link its url here.
-
#enterprise ⇒ Object
(also: #enterprise?)
readonly
Is this an enterprise-only replicator?.
-
#feature_roles ⇒ Object
Used for feature flagging functionality.
-
#install_url ⇒ Object
readonly
If this integration uses /v1/install to set up, or some other link like a marketplace URL, provide it here.
-
#name ⇒ Object
Name of the replicator, like ‘stripe_charge_v1’.
-
#resource_name_plural ⇒ Object
Defaults to resource_name_singular+s.
-
#resource_name_singular ⇒ Object
Name of the resource, like “Acme Sprocket” @return [String].
-
#supports_backfill ⇒ Object
(also: #supports_backfill?)
readonly
True if this integration supports user-driven backfilling, usually by paginating all resources.
-
#supports_webhooks ⇒ Object
(also: #supports_webhooks?)
readonly
True if this integration supports webhooks (real-time or user-built webhook payloads).
Instance Method Summary collapse
- #==(other) ⇒ Object
- #backfill_only? ⇒ Boolean
- #documentable? ⇒ Boolean
-
#initialize(name:, ctor:, resource_name_singular:, feature_roles:, supports_webhooks: false, supports_backfill: false, resource_name_plural: nil, dependency_descriptor: nil, api_docs_url: "", description: nil, enterprise: false, documentation_url: nil, install_url: nil, documentable: nil) ⇒ Descriptor
constructor
A new instance of Descriptor.
- #inspect ⇒ Object
- #supports_webhooks_and_backfill? ⇒ Boolean
- #webhooks_only? ⇒ Boolean
Methods inherited from TypedStruct
#[], #_apply, #_defaults, #as_json, #change
Constructor Details
#initialize(name:, ctor:, resource_name_singular:, feature_roles:, supports_webhooks: false, supports_backfill: false, resource_name_plural: nil, dependency_descriptor: nil, api_docs_url: "", description: nil, enterprise: false, documentation_url: nil, install_url: nil, documentable: nil) ⇒ Descriptor
Returns a new instance of Descriptor.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/webhookdb/replicator.rb', line 93 def initialize( name:, ctor:, resource_name_singular:, feature_roles:, supports_webhooks: false, supports_backfill: false, resource_name_plural: nil, dependency_descriptor: nil, api_docs_url: "", description: nil, enterprise: false, documentation_url: nil, install_url: nil, documentable: nil ) raise ArgumentError, "must support one or both of webhooks and backfill" unless supports_webhooks || supports_backfill super( name:, resource_name_singular:, feature_roles:, supports_webhooks:, supports_backfill:, dependency_descriptor:, documentation_url:, api_docs_url:, install_url:, enterprise: ) @ctor = ctor.is_a?(Class) ? ctor.method(:new) : ctor @resource_name_plural = resource_name_plural || "#{self.resource_name_singular}s" @description = description || "Replicate #{self.resource_name_plural} into your database." @documentable = documentable.nil? ? !self.name.start_with?("webhookdb_", "fake_", "theranest_") : documentable end |
Instance Attribute Details
#api_docs_url ⇒ Object (readonly)
URL pointing to the provider (not-WebhookDB) docs for this integration.
86 87 88 |
# File 'lib/webhookdb/replicator.rb', line 86 def api_docs_url @api_docs_url end |
#ctor ⇒ Object
Method invoked with the Webhookdb::ServiceIntegration
, and should return a new instance of the integration. Can also be an object that responds to ‘new`.
@return [Proc]
39 40 41 |
# File 'lib/webhookdb/replicator.rb', line 39 def ctor @ctor end |
#dependency_descriptor ⇒ Object
The descriptor for the service this one depends on (the parent).
@return [Webhookdb::Replicator::Descriptor]
63 64 65 |
# File 'lib/webhookdb/replicator.rb', line 63 def dependency_descriptor @dependency_descriptor end |
#description ⇒ Object (readonly)
Markdown description of this replicator.
83 84 85 |
# File 'lib/webhookdb/replicator.rb', line 83 def description @description end |
#documentation_url ⇒ Object (readonly)
If this integration has specific documentation, link its url here. It is used to build custom error messages, for example in case ‘backfill’ is called but not supported.
74 75 76 |
# File 'lib/webhookdb/replicator.rb', line 74 def documentation_url @documentation_url end |
#enterprise ⇒ Object (readonly) Also known as: enterprise?
Is this an enterprise-only replicator?
89 90 91 |
# File 'lib/webhookdb/replicator.rb', line 89 def enterprise @enterprise end |
#feature_roles ⇒ Object
Used for feature flagging functionality. Usually will be [], but other possible values are: -‘internal’ e.g. our fake integration -‘unreleased’ for works in progress -‘beta’ if we don’t want most people to have access
@return [Array<String>]
48 49 50 |
# File 'lib/webhookdb/replicator.rb', line 48 def feature_roles @feature_roles end |
#install_url ⇒ Object (readonly)
If this integration uses /v1/install to set up, or some other link like a marketplace URL, provide it here. Note that you can add a redirect to Webhookdb::Apps::REDIRECTS to provide a pretty, arbitrary URL.
80 81 82 |
# File 'lib/webhookdb/replicator.rb', line 80 def install_url @install_url end |
#name ⇒ Object
Name of the replicator, like ‘stripe_charge_v1’. Appears externally in many places, so must be meaningful.
@return [String]
33 34 35 |
# File 'lib/webhookdb/replicator.rb', line 33 def name @name end |
#resource_name_plural ⇒ Object
Defaults to resource_name_singular+s.
@return [String]
58 59 60 |
# File 'lib/webhookdb/replicator.rb', line 58 def resource_name_plural @resource_name_plural end |
#resource_name_singular ⇒ Object
Name of the resource, like “Acme Sprocket”
@return [String]
53 54 55 |
# File 'lib/webhookdb/replicator.rb', line 53 def resource_name_singular @resource_name_singular end |
#supports_backfill ⇒ Object (readonly) Also known as: supports_backfill?
True if this integration supports user-driven backfilling, usually by paginating all resources.
69 70 71 |
# File 'lib/webhookdb/replicator.rb', line 69 def supports_backfill @supports_backfill end |
#supports_webhooks ⇒ Object (readonly) Also known as: supports_webhooks?
True if this integration supports webhooks (real-time or user-built webhook payloads).
66 67 68 |
# File 'lib/webhookdb/replicator.rb', line 66 def supports_webhooks @supports_webhooks end |
Instance Method Details
#==(other) ⇒ Object
133 134 135 136 137 |
# File 'lib/webhookdb/replicator.rb', line 133 def ==(other) return self.class == other.class && self.name == other.name && self.resource_name_singular == other.resource_name_singular end |
#backfill_only? ⇒ Boolean
143 |
# File 'lib/webhookdb/replicator.rb', line 143 def backfill_only? = !self.supports_webhooks? && self.supports_backfill? |
#documentable? ⇒ Boolean
91 |
# File 'lib/webhookdb/replicator.rb', line 91 def documentable? = @documentable |
#inspect ⇒ Object
129 130 131 |
# File 'lib/webhookdb/replicator.rb', line 129 def inspect return "#{self.class.name}(name: #{self.name})" end |
#supports_webhooks_and_backfill? ⇒ Boolean
144 |
# File 'lib/webhookdb/replicator.rb', line 144 def supports_webhooks_and_backfill? = self.supports_webhooks? && self.supports_backfill? |
#webhooks_only? ⇒ Boolean
142 |
# File 'lib/webhookdb/replicator.rb', line 142 def webhooks_only? = self.supports_webhooks? && !self.supports_backfill? |