Sha256: 59f002e223bca60286cbe9ae383e76fe0469bfd1be07c63b46a7705a5cef4ff0

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

module RailsAdmin
  module Config
    module Proxyable
      class Proxy < BasicObject
        def initialize(object, bindings = {})
          @object = object
          @bindings = bindings
        end

        # Bind variables to be used by the configuration options
        def bind(key, value = nil)
          if key.is_a?(::Hash)
            @bindings = key
          else
            @bindings[key] = value
          end
          self
        end

        def method_missing(name, *args, &block)
          if @object.respond_to?(name)
            reset = @object.bindings
            begin
              @object.bindings = @bindings
              response = @object.__send__(name, *args, &block)
            ensure
              @object.bindings = reset
            end
            response
          else
            super(name, *args, &block)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_admin-2.0.1 lib/rails_admin/config/proxyable/proxy.rb
rails_admin-2.0.0 lib/rails_admin/config/proxyable/proxy.rb
rails_admin-2.0.0.rc lib/rails_admin/config/proxyable/proxy.rb
rails_admin-2.0.0.beta lib/rails_admin/config/proxyable/proxy.rb