Sha256: b002edb67377364bfd77cca10916937bb090047e1ecc1d642523b6b519b799cc

Contents?: true

Size: 1010 Bytes

Versions: 7

Compression:

Stored size: 1010 Bytes

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'
              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

7 entries across 7 versions & 2 rubygems

Version Path
jferris-rr-0.7.1.0.1239654108 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.2 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.10.0 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.8.0 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.8.1 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.9.0 lib/rr/double_definitions/double_definition_creator_proxy.rb
rr-0.7.1 lib/rr/double_definitions/double_definition_creator_proxy.rb