Class: Apis::ConnectionScope
- Inherits:
-
Object
- Object
- Apis::ConnectionScope
- Defined in:
- lib/apis/connection_scope.rb
Instance Method Summary collapse
-
#initialize ⇒ ConnectionScope
constructor
A new instance of ConnectionScope.
- #method_missing(method, value = nil) ⇒ Object
- #scoped ⇒ Object
Constructor Details
#initialize ⇒ ConnectionScope
Returns a new instance of ConnectionScope.
3 4 5 |
# File 'lib/apis/connection_scope.rb', line 3 def initialize @data = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, value = nil) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/apis/connection_scope.rb', line 7 def method_missing(method, value = nil) if method =~ /\=$/ && value @data[method.to_s.gsub(/\=/, '').to_sym] = value else @data[method] end end |
Instance Method Details
#scoped ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/apis/connection_scope.rb', line 15 def scoped backup = {} @data.each do |key, value| backup[key] = value.dup end yield ensure backup.each do |key, value| @data[key] = value end end |