Class: Obfuscate::Config
- Inherits:
-
Object
- Object
- Obfuscate::Config
- Defined in:
- lib/obfuscate/config.rb
Overview
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Attribute Summary collapse
-
#encode ⇒ Object
Returns the value of attribute encode.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#remove_trailing_equal ⇒ Object
Returns the value of attribute remove_trailing_equal.
-
#salt ⇒ Object
Returns the value of attribute salt.
Instance Method Summary collapse
-
#apply(options = {}, &blk) {|config| ... } ⇒ Obfuscate::Config
Creates a new instance of Config with applied changes.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#remove_trailing_equal? ⇒ Boolean
Check if mode is :block and remove_trailing_equal is true.
-
#to_hash ⇒ Hash
Hash of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
19 20 21 22 23 24 |
# File 'lib/obfuscate/config.rb', line 19 def initialize # defaults @remove_trailing_equal = true @encode = true @mode = :string end |
Instance Attribute Details
#encode ⇒ Object
Returns the value of attribute encode.
17 18 19 |
# File 'lib/obfuscate/config.rb', line 17 def encode @encode end |
#mode ⇒ Object
Returns the value of attribute mode.
17 18 19 |
# File 'lib/obfuscate/config.rb', line 17 def mode @mode end |
#remove_trailing_equal ⇒ Object
Returns the value of attribute remove_trailing_equal.
17 18 19 |
# File 'lib/obfuscate/config.rb', line 17 def remove_trailing_equal @remove_trailing_equal end |
#salt ⇒ Object
Returns the value of attribute salt.
17 18 19 |
# File 'lib/obfuscate/config.rb', line 17 def salt @salt end |
Instance Method Details
#apply(options = {}, &blk) {|config| ... } ⇒ Obfuscate::Config
Creates a new instance of Config with applied changes. Does not change the original Config.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/obfuscate/config.rb', line 55 def apply( = {}, &blk) config = self.class.new changes = self.to_hash.merge( ) config.salt = changes[:salt] unless changes[:salt].nil? config.mode = changes[:mode] unless changes[:mode].nil? config.encode = changes[:encode] unless changes[:encode].nil? config.remove_trailing_equal = changes[:remove_trailing_equal] unless changes[:remove_trailing_equal].nil? yield(config) if blk config end |
#remove_trailing_equal? ⇒ Boolean
Check if mode is :block and remove_trailing_equal is true
41 42 43 |
# File 'lib/obfuscate/config.rb', line 41 def remove_trailing_equal? self.mode == :block && self.remove_trailing_equal == true end |
#to_hash ⇒ Hash
Hash of Config
73 74 75 |
# File 'lib/obfuscate/config.rb', line 73 def to_hash { :salt => salt, :mode => mode, :encode => encode, :remove_trailing_equal => remove_trailing_equal } end |