Class: Chamber::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/chamber/instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Instance

Returns a new instance of Instance.



12
13
14
15
# File 'lib/chamber/instance.rb', line 12

def initialize(**args)
  self.configuration = Configuration.new(**args)
  self.files         = FileSet.new(**configuration.to_hash)
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



9
10
11
# File 'lib/chamber/instance.rb', line 9

def configuration
  @configuration
end

#filesObject

Returns the value of attribute files.



9
10
11
# File 'lib/chamber/instance.rb', line 9

def files
  @files
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/chamber/instance.rb', line 21

def [](key)
  settings.[](key)
end

#decrypt(data, **args) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/chamber/instance.rb', line 83

def decrypt(data, **args)
  config = configuration.to_hash.merge(**args)

  Settings
    .new(
      **config.merge(
        settings:     data,
        pre_filters:  [Filters::NamespaceFilter],
        post_filters: [
                        Filters::DecryptionFilter,
                        Filters::FailedDecryptionFilter,
                      ],
      ),
    )
    .to_hash
end

#dig(*args) ⇒ Object



29
30
31
# File 'lib/chamber/instance.rb', line 29

def dig(*args)
  settings.dig(*args)
end

#dig!(*args) ⇒ Object



25
26
27
# File 'lib/chamber/instance.rb', line 25

def dig!(*args)
  settings.dig!(*args)
end

#encrypt(data, **args) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/chamber/instance.rb', line 69

def encrypt(data, **args)
  config = configuration.to_hash.merge(**args)

  Settings
    .new(
      **config.merge(
        settings:     data,
        pre_filters:  [Filters::EncryptionFilter],
        post_filters: [],
      ),
    )
    .to_hash
end

#filenamesObject



33
34
35
# File 'lib/chamber/instance.rb', line 33

def filenames
  files.filenames
end

#namespacesObject



65
66
67
# File 'lib/chamber/instance.rb', line 65

def namespaces
  settings.namespaces
end

#secureObject



37
38
39
# File 'lib/chamber/instance.rb', line 37

def secure
  files.secure
end

#settingsObject



17
18
19
# File 'lib/chamber/instance.rb', line 17

def settings
  @settings ||= files.to_settings { |settings| @settings = settings }
end

#signObject



45
46
47
# File 'lib/chamber/instance.rb', line 45

def sign
  files.sign
end

#to_environmentObject



53
54
55
# File 'lib/chamber/instance.rb', line 53

def to_environment
  settings.to_environment
end

#to_hashObject



61
62
63
# File 'lib/chamber/instance.rb', line 61

def to_hash
  settings.to_hash
end

#to_s(**args) ⇒ Object



57
58
59
# File 'lib/chamber/instance.rb', line 57

def to_s(**args)
  settings.to_s(**args)
end

#unsecureObject



41
42
43
# File 'lib/chamber/instance.rb', line 41

def unsecure
  files.unsecure
end

#verifyObject



49
50
51
# File 'lib/chamber/instance.rb', line 49

def verify
  files.verify
end