Class: RailsAdminSettings::Fallback
- Inherits:
- BasicObject
- Defined in:
- lib/rails_admin_settings/fallback.rb
Overview
we are inheriting from BasicObject so we don’t get a bunch of methods from Kernel or Object
Constant Summary collapse
- DELEGATE =
[:puts, :p, :block_given?].freeze
Instance Method Summary collapse
-
#initialize(ns, fb) ⇒ Fallback
constructor
A new instance of Fallback.
- #inspect ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(ns, fb) ⇒ Fallback
Returns a new instance of Fallback.
8 9 10 11 |
# File 'lib/rails_admin_settings/fallback.rb', line 8 def initialize(ns, fb) @ns = ns @fb = fb end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rails_admin_settings/fallback.rb', line 17 def method_missing(name, *args, &block) return ::Kernel.send(name, *args, &block) if DELEGATE.include?(name) @ns.ns_mutex.synchronize do @ns.fallback = @fb @ns.__send__(name, *args, &block) end end |
Instance Method Details
#inspect ⇒ Object
13 14 15 |
# File 'lib/rails_admin_settings/fallback.rb', line 13 def inspect "#<RailsAdminSettings::Fallback ns: #{@ns.inspect}, fb: #{@fb.inspect}>".freeze end |