Class: Kinko::Adapters::ROM::Plugin::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/kinko/adapters/rom/plugin.rb

Defined Under Namespace

Classes: Encrypted, Indexed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



16
17
18
19
20
# File 'lib/kinko/adapters/rom/plugin.rb', line 16

def initialize
  @encrypted = []
  @indexed = []
  @normalizers = {}
end

Instance Attribute Details

#encryptedObject (readonly)

Returns the value of attribute encrypted.



14
15
16
# File 'lib/kinko/adapters/rom/plugin.rb', line 14

def encrypted
  @encrypted
end

#indexedObject (readonly)

Returns the value of attribute indexed.



14
15
16
# File 'lib/kinko/adapters/rom/plugin.rb', line 14

def indexed
  @indexed
end

#normalizersObject (readonly)

Returns the value of attribute normalizers.



14
15
16
# File 'lib/kinko/adapters/rom/plugin.rb', line 14

def normalizers
  @normalizers
end

Instance Method Details

#blind_index(source, to:, normalize: :none) ⇒ Object



27
28
29
30
# File 'lib/kinko/adapters/rom/plugin.rb', line 27

def blind_index(source, to:, normalize: :none)
  @indexed << Indexed.new(source:, to:, normalize:)
  @normalizers[to] = normalize
end

#decrypt_output(tuple) ⇒ Object



39
40
41
42
43
# File 'lib/kinko/adapters/rom/plugin.rb', line 39

def decrypt_output(tuple)
  result = tuple.to_h.dup
  @encrypted.each { apply_decrypt(_1, result) if result.key?(_1.to) }
  result
end

#encrypt(source, to:, index: nil, normalize: :none, type: nil) ⇒ Object



22
23
24
25
# File 'lib/kinko/adapters/rom/plugin.rb', line 22

def encrypt(source, to:, index: nil, normalize: :none, type: nil)
  @encrypted << Encrypted.new(source:, to:, index:, normalize:, type:)
  @normalizers[index] = normalize if index
end

#encrypt_input(tuple) ⇒ Object



32
33
34
35
36
37
# File 'lib/kinko/adapters/rom/plugin.rb', line 32

def encrypt_input(tuple)
  result = tuple.to_h.dup
  @encrypted.each { apply_encrypt(_1, result) if result.key?(_1.source) }
  @indexed.each { apply_index(_1, result) if result.key?(_1.source) }
  result
end