Module: Blender::Discovery

Includes:
Utils::Refinements
Included in:
SchedulerDSL, Task::Base
Defined in:
lib/blender/rspec.rb,
lib/blender/discovery.rb

Instance Method Summary collapse

Methods included from Utils::Refinements

#camelcase, #symbolize

Instance Method Details

#build_discovery(type, opts = {}) ⇒ Object



24
25
26
27
28
# File 'lib/blender/discovery.rb', line 24

def build_discovery(type, opts = {})
  disco_klass = Blender::Discovery.const_get(camelcase(type.to_s).to_sym)
  disco_opts = blender_config(type).merge(opts)
  disco_klass.new(symbolize(disco_opts))
end

#old_searchObject



30
# File 'lib/blender/rspec.rb', line 30

alias_method :old_search, :search

#search(type, options = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/blender/rspec.rb', line 31

def search(type, options = nil)
  stub = Blender::RSpec::StubRegistry.instance.data.detect do |st|
    st.type == type && st.opts == options
  end
  if stub
    stub.return_value
  else
    old_search(type, options)
  end
end

#search_with_config(type, opts = {}) ⇒ Object



30
31
32
33
34
# File 'lib/blender/discovery.rb', line 30

def search_with_config(type, opts = {})
  options = opts.dup
  search_opts = options.delete(:search)
  build_discovery(type, options).search(search_opts)
end