Class: ThecoreSettings::Fallback

Inherits:
BasicObject
Defined in:
lib/thecore_settings/fallback.rb

Overview

we are inheriting from BasicObject so we don’t get a bunch of methods from Kernel or Object

Instance Method Summary collapse

Constructor Details

#initialize(ns, fb) ⇒ Fallback

Returns a new instance of Fallback.



5
6
7
8
# File 'lib/thecore_settings/fallback.rb', line 5

def initialize(ns, fb)
  @ns = ns
  @fb = fb
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



14
15
16
17
18
19
# File 'lib/thecore_settings/fallback.rb', line 14

def method_missing(*args)
  @ns.ns_mutex.synchronize do
    @ns.fallback = @fb
    @ns.__send__(*args)
  end
end

Instance Method Details

#inspectObject



10
11
12
# File 'lib/thecore_settings/fallback.rb', line 10

def inspect
  "#<ThecoreSettings::Fallback ns: #{@ns.inspect}, fb: #{@fb.inspect}>"
end