Sha256: 779c7e34a55b0e3d15a4406fc76940429c3703a3d1678fe27f30f91eba1e6c49

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module RR
  module DoubleDefinitions
    class DoubleDefinitionCreatorProxy
      class << self
        def blank_slate_methods
          instance_methods.each do |m|
            unless m =~ /^_/ || m.to_s == 'object_id' || m.to_s == 'respond_to?' || m.to_s == 'method_missing' || m.to_s == 'instance_eval' || m.to_s == 'instance_exec'
              alias_method "__blank_slated_#{m}", m
              undef_method m
            end
          end
        end
      end

      def initialize(creator, &block) #:nodoc:
        @creator = creator
        respond_to?(:class) ? self.class.blank_slate_methods : __blank_slated_class.blank_slate_methods

        if block_given?
          if block.arity == 1
            yield(self)
          else
            respond_to?(:instance_eval) ? instance_eval(&block) : __blank_slated_instance_eval(&block)
          end
        end
      end

      def method_missing(method_name, *args, &block)
        @creator.create(method_name, *args, &block)
      end

      def __creator__
        @creator
      end
    end    
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
redinger-redinger-rr-0.10.3 lib/rr/double_definitions/double_definition_creator_proxy.rb
redinger-rr-0.10.4 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.10 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.9 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.8 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.7 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.6 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.5 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.4 lib/rr/double_definitions/double_definition_creator_proxy.rb
redinger-rr-0.10.3 lib/rr/double_definitions/double_definition_creator_proxy.rb