Class: Trabox::Publisher::Google::Cloud::PubSub::OrderingKey
- Inherits:
-
Object
- Object
- Trabox::Publisher::Google::Cloud::PubSub::OrderingKey
- Defined in:
- lib/trabox/publisher/google/cloud_pubsub.rb
Instance Method Summary collapse
- #call(*args) ⇒ String
-
#initialize(key) ⇒ OrderingKey
constructor
A new instance of OrderingKey.
Constructor Details
#initialize(key) ⇒ OrderingKey
Returns a new instance of OrderingKey.
15 16 17 18 19 20 21 22 23 |
# File 'lib/trabox/publisher/google/cloud_pubsub.rb', line 15 def initialize(key) @key = if key.is_a?(Proc) key elsif key.instance_of?(String) ->(*) { key } else raise ArgumentError, 'OrderingKey.new should be set to Proc or String.' end end |
Instance Method Details
#call(*args) ⇒ String
26 27 28 29 30 31 32 |
# File 'lib/trabox/publisher/google/cloud_pubsub.rb', line 26 def call(*args) key = @key.call(*args) raise 'OrderingKey#call should be returned String type.' unless key.instance_of?(String) key end |