Module: RSpec::Core::Extensions::ModuleEvalWithArgs

### Home Classes Methods

### In Files

- lib/rspec/core/extensions/module_eval_with_args.rb

### Methods

- #module_eval_with_args

### Included Modules

- RSpec::Core::Extensions::InstanceEvalWithArgs

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::BacktraceCleaner
- RSpec::Core::BacktraceFormatter
- RSpec::Core::CommandLine
- RSpec::Core::Configuration
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::ConstMissing
- RSpec::Core::DRbCommandLine
- RSpec::Core::DSL
- RSpec::Core::Deprecation
- RSpec::Core::DrbOptions
- RSpec::Core::Example
- RSpec::Core::Example::NotPendingExampleFixed
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::Extensions
- RSpec::Core::Extensions::InstanceEvalWithArgs
- RSpec::Core::Extensions::ModuleEvalWithArgs
- RSpec::Core::Extensions::Ordered
- RSpec::Core::Extensions::Ordered::ExampleGroups
- RSpec::Core::Extensions::Ordered::Examples
- RSpec::Core::FilterManager
- RSpec::Core::FilterManager::BackwardCompatibility
- RSpec::Core::FilterManager::Describable
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::Formatters::TextMateFormatter
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterAllHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::AroundHookCollection
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::GroupHookCollection
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollection
- RSpec::Core::Hooks::HookCollectionAliases
- RSpec::Core::Hooks::RegistersGlobals
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::BeforeAllMemoizedHash
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleMetadataHash
- RSpec::Core::Metadata::GroupMetadataHash
- RSpec::Core::Metadata::MetadataHash
- RSpec::Core::MetadataHashBuilder
- RSpec::Core::MetadataHashBuilder::Common
- RSpec::Core::MetadataHashBuilder::WithConfigWarning
- RSpec::Core::MetadataHashBuilder::WithDeprecationWarning
- RSpec::Core::MockFrameworkAdapter
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingDeclaredInExample
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Collection
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::World
- RSpec::Rake
- RSpec::Runner
- Autotest
- Autotest::Rspec2
- Kernel

No matching classes.

# RSpec::Core::Extensions::ModuleEvalWithArgs

@private

### Public Instance Methods

module_eval_with_args(*args, &block) click to toggle source

@private

Used internally to support `module_exec` in Ruby 1.8.6.

    # File lib/rspec/core/extensions/module_eval_with_args.rb, line 11
    def module_eval_with_args(*args, &block)
      # ruby > 1.8.6
      return module_exec(*args, &block) if respond_to?(:module_exec)

      # If there are no args and the block doesn't expect any, there's no
      # need to fake module_exec with our hack below.
      # Notes:
      #   * lambda {      }.arity # => -1
      #   * lambda { ||   }.arity # =>  0
      #   * lambda { |*a| }.arity # => -1
      return module_eval(&block) if block.arity < 1 && args.size.zero?

      orig_singleton_methods = singleton_methods
      instance_eval_with_args(*args, &block)

      # The only difference between instance_eval and module_eval is static method defs.
      #   * `def foo` in instance_eval defines a singleton method on the instance
      #   * `def foo` in class/module_eval defines an instance method for the class/module
      # Here we deal with this difference by defining an instance method for
      # each new singleton method.
      # This has the side effect of duplicating methods (all new class methods will
      # become instance methods and vice versa), but I don't see a way around it...
      (singleton_methods - orig_singleton_methods).each { |m| define_method(m, &method(m)) }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.