README.md in umbrellio-sequel-plugins-0.4.0.121 vs README.md in umbrellio-sequel-plugins-0.4.0.134
- old
+ new
@@ -11,33 +11,34 @@
gem 'umbrellio-sequel-plugins'
```
And then execute:
- $ bundle
+$ bundle
# Extensions
-- `CurrencyRates`
-- `PGTools`
-- `Slave`
-- `Synchronize`
-- `methods_in_migrations`
-- `deferrable_foreign_keys`
+- [`CurrencyRates`](#CurrencyRates)
+- [`PGTools`](#PGTools)
+- [`Slave`](#Slave)
+- [`Synchronize`](#Synchronize)
+- [`methods_in_migrations`](#methods_in_migrations)
+- [`deferrable_foreign_keys`](#deferrable_foreign_keys)
# Plugins
-- `Duplicate`
-- `GetColumnValue`
-- `MoneyAccessors`
-- `StoreAccessors`
-- `Synchronize`
-- `Upsert`
-- `WithLock`
+- [`AttrEncrypted`](#AttrEncrypted)
+- [`Duplicate`](#Duplicate)
+- [`GetColumnValue`](#GetColumnValue)
+- [`MoneyAccessors`](#MoneyAccessors)
+- [`StoreAccessors`](#StoreAccessors)
+- [`Synchronize`](#Synchronize)
+- [`Upsert`](#Upsert)
+- [`WithLock`](#WithLock)
# Tools
-- `TimestampMigratorUndoExtension`
+- [`TimestampMigratorUndoExtension`](#TimestampMigratorUndoExtension)
## CurrencyRates
Plugin for joining currency rates table to any other table and money exchange.
@@ -199,9 +200,43 @@
# without extension:
# => Sequel::ForeignKeyConstraintViolation: Key (husband_id)=(123456789) is not present in table "husbands".
# with extension:
# => <Wife @attributes={id:1, husband_id: 1}>
# => <Husband @attributes={id:1, wife_id: 1}>
+```
+
+## AttrEncrypted
+
+Enable: `Sequel::Model.plugin :attr_encrypted`
+
+Plugin for storing encrypted model attributes.
+
+Example:
+
+```ruby
+Sequel.migration do
+ change do
+ alter_table :orders do
+ add_column :encrypted_first_name, :text
+ add_column :encrypted_last_name, :text
+ add_column :encrypted_secret_data, :text
+ end
+ end
+end
+
+class Order < Sequel::Model
+ attr_encrypted :first_name, :last_name, key: Settings.private_key
+ attr_encrypted :secret_data, key: Settings.another_private_key, json: true
+end
+
+Order.create(first_name: "Ivan")
+# => INSERT INTO "orders" ("encrypted_first_name") VALUES ('/sTi9Q==$OTpuMRq5k8R3JayQ$WjSManQGP9UaZ3C40yDjKg==')
+
+order = Order.create(first_name: "Ivan", last_name: "Smith",
+ secret_data: { "some_key" => "Some Value" })
+order.reload
+order.first_name # => "Ivan"
+order.secret_data # => { "some_key" => "Some Value" }
```
## Duplicate
Enable: `Sequel::Model.plugin :duplicate`