Class: Ruboty::Handlers::RubyPersistence
- Inherits:
-
Base
- Object
- Base
- Ruboty::Handlers::RubyPersistence
- Defined in:
- lib/ruboty/handlers/ruby_persistence.rb
Constant Summary collapse
- NAMESPACE =
'ruby_persistence'.freeze
Instance Method Summary collapse
-
#initialize ⇒ RubyPersistence
constructor
A new instance of RubyPersistence.
- #set(message) ⇒ Object
- #unset(message) ⇒ Object
Constructor Details
#initialize ⇒ RubyPersistence
Returns a new instance of RubyPersistence.
20 21 22 23 |
# File 'lib/ruboty/handlers/ruby_persistence.rb', line 20 def initialize(*) super restore end |
Instance Method Details
#set(message) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/ruboty/handlers/ruby_persistence.rb', line 25 def set() name = [:name] if !variables.key?(name) && (method = predefined_method(name)) .reply("Error: `#{name}` is predefined by `#{method.owner}`") else define_and_persist_variable() end end |
#unset(message) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruboty/handlers/ruby_persistence.rb', line 35 def unset() name = [:name] if variables[name] undefine_variable(name) variables.delete(name) .reply("`#{name}` is now unset") else .reply("Error: No such variable `#{name}`") end end |