Class: RSpec::OpenHAB::Core::Mocks::BundleResolver

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rspec/openhab/core/mocks/bundle_resolver.rb

Instance Method Summary collapse

Constructor Details

#initializeBundleResolver

Returns a new instance of BundleResolver.



13
14
15
# File 'lib/rspec/openhab/core/mocks/bundle_resolver.rb', line 13

def initialize
  @classes = {}
end

Instance Method Details

#register_class(klass, bundle) ⇒ Object



17
18
19
20
# File 'lib/rspec/openhab/core/mocks/bundle_resolver.rb', line 17

def register_class(klass, bundle)
  # ensure we have an individual java class already
  @classes[klass.become_java!] = bundle
end

#resolve_bundle(clazz) ⇒ Object



22
23
24
25
26
27
# File 'lib/rspec/openhab/core/mocks/bundle_resolver.rb', line 22

def resolve_bundle(clazz)
  bundle = @classes[clazz]
  return bundle if bundle

  org.osgi.framework.FrameworkUtil.get_bundle(clazz)
end