Class: Workato::Types::Binary
- Inherits:
-
String
- Object
- String
- Workato::Types::Binary
- Defined in:
- lib/workato/types/binary.rb
Overview
Explicit wrapper for binary data
Workato runtime always converts a String to UnicodeString and binary data to Binary before execute an action.
Call action or trigger by name
SDK emulator applies trigger’s or action’s input/output schema and normalize string when invoke them by name. If you call an operation like this, then emulator passes input with UnicodeString or Binary to the operation
CLI
workato exec 'actions.test_action'
workato exec 'triggers.test_poll_trigger'
RSpec
connector.actions.test_action.invoke(input)
connector.triggers.test_poll_trigger.invoke(input)
Direct call to execute or poll block
Schema is not applied when call an action’s execute block directly. For example
CLI
workato exec 'actions.test_action.execute'
RSpec
connector.actions.test_action.execute(settings, input, input_schema, output_schema)
In that case if action’s code relies on methods of UnicodeString or Binary then this explicit wrapper should be used for correct behavior.
Constant Summary collapse
- TITLE_LENGTH =
16- SUMMARY_LENGTH =
128
Instance Method Summary collapse
- #as_string(encoding) ⇒ Object
- #as_utf8 ⇒ Object
- #base64 ⇒ Object
-
#binary? ⇒ Boolean
Returns true for binary data.
-
#initialize(str) ⇒ Binary
constructor
A new instance of Binary.
- #sha1 ⇒ Object
- #to_json(_options = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ Binary
Returns a new instance of Binary.
51 52 53 54 |
# File 'lib/workato/types/binary.rb', line 51 def initialize(str) super force_encoding(Encoding::ASCII_8BIT) end |
Instance Method Details
#as_string(encoding) ⇒ Object
75 76 77 |
# File 'lib/workato/types/binary.rb', line 75 def as_string(encoding) ::String.new(self, encoding: encoding).encode(encoding, invalid: :replace, undef: :replace) end |
#as_utf8 ⇒ Object
79 80 81 |
# File 'lib/workato/types/binary.rb', line 79 def as_utf8 as_string('utf-8') end |
#base64 ⇒ Object
71 72 73 |
# File 'lib/workato/types/binary.rb', line 71 def base64 Base64.strict_encode64(self) end |
#binary? ⇒ Boolean
Returns true for binary data
67 68 69 |
# File 'lib/workato/types/binary.rb', line 67 def binary? true end |
#sha1 ⇒ Object
83 84 85 |
# File 'lib/workato/types/binary.rb', line 83 def sha1 Binary.new(::Digest::SHA1.digest(self)) end |
#to_json(_options = nil) ⇒ Object
60 61 62 |
# File 'lib/workato/types/binary.rb', line 60 def to_json( = nil) summary end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/workato/types/binary.rb', line 56 def to_s self end |