Class: BotChallengePage::Config
- Inherits:
-
Object
- Object
- BotChallengePage::Config
- Defined in:
- lib/bot_challenge_page/config.rb
Class Method Summary collapse
-
.attribute(name, default: nil) ⇒ Object
default can be a proc, in which case it really is a proc as a value for default, the value is the proc!.
Instance Method Summary collapse
-
#initialize(**values) ⇒ Config
constructor
A new instance of Config.
-
#initialize_dup(source) ⇒ Object
make sure dup dups all attributes please.
Constructor Details
#initialize(**values) ⇒ Config
Returns a new instance of Config.
14 15 16 17 18 |
# File 'lib/bot_challenge_page/config.rb', line 14 def initialize(**values) self.class.attr_defaults.merge(values).each_pair do |key, value| send("#{key}=", value) end end |
Class Method Details
.attribute(name, default: nil) ⇒ Object
default can be a proc, in which case it really is a proc as a value for default, the value is the proc!
7 8 9 10 |
# File 'lib/bot_challenge_page/config.rb', line 7 def self.attribute(name, default:nil) attr_defaults[name] = default self.attr_accessor name end |
Instance Method Details
#initialize_dup(source) ⇒ Object
make sure dup dups all attributes please
96 97 98 99 100 101 |
# File 'lib/bot_challenge_page/config.rb', line 96 def initialize_dup(source) self.class.attr_defaults.keys.each do |attr_key| instance_variable_set("@#{attr_key}", instance_variable_get("@#{attr_key}").deep_dup) super end end |