Class: Sequel::Plugins::ColumnEncryption::ColumnDSL
- Defined in:
- lib/sequel/plugins/column_encryption.rb
Overview
The object type yielded to blocks passed to the column
method inside plugin :column_encryption
blocks. This is used to configure custom per-column keys.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
An array of arrays for the data for the keys configured inside the block.
Instance Method Summary collapse
-
#initialize ⇒ ColumnDSL
constructor
A new instance of ColumnDSL.
-
#key(key_id, key, opts = OPTS) ⇒ Object
Verify that the key_id, key, and options are value.
Constructor Details
#initialize ⇒ ColumnDSL
Returns a new instance of ColumnDSL.
544 545 546 |
# File 'lib/sequel/plugins/column_encryption.rb', line 544 def initialize @keys = [] end |
Instance Attribute Details
#keys ⇒ Object (readonly)
An array of arrays for the data for the keys configured inside the block.
542 543 544 |
# File 'lib/sequel/plugins/column_encryption.rb', line 542 def keys @keys end |
Instance Method Details
#key(key_id, key, opts = OPTS) ⇒ Object
Verify that the key_id, key, and options are value.
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/sequel/plugins/column_encryption.rb', line 549 def key(key_id, key, opts=OPTS) unless key_id.is_a?(Integer) && key_id >= 0 && key_id <= 255 raise Error, "invalid key_id argument, must be integer between 0 and 255" end unless key.is_a?(String) && key.bytesize == 32 raise Error, "invalid key argument, must be string with exactly 32 bytes" end if opts.has_key?(:padding) if padding = opts[:padding] unless padding.is_a?(Integer) && padding >= 1 && padding <= 120 raise Error, "invalid :padding option, must be between 1 and 120" end end else padding = Cryptor::DEFAULT_PADDING end @keys << [key_id, key, opts[:auth_data].to_s, padding].freeze end |