class Knowledge::Setters::Knowledge
Description¶ ↑
If you don't have a defined strategy to manage config for your project, you can use Knowledge's one. This is the custom setter.
Usage¶ ↑
@example:
Knowledge::Setters::Knowledge.new.set(name: :foo, value: 'bar')
Attributes¶ ↑
@attr_reader [Knowledge::Configuration] configuration
Public Class Methods
new()
click to toggle source
Just sets the basic configuration object.
# File lib/knowledge/setters/knowledge.rb, line 29 def initialize @configuration = ::Knowledge::Configuration end
Public Instance Methods
set(name:, value:)
click to toggle source
Sets the variable by doing black magic on Knowledge::Configuration
.
Parameters¶ ↑
@param :name [String | Symbol] @param :value [Any]
# File lib/knowledge/setters/knowledge.rb, line 43 def set(name:, value:) @configuration.singleton_class.class_eval { attr_accessor name.to_sym } unless @configuration.respond_to?(name) @configuration.instance_variable_set(:"@#{name}", value) end