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

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

Instance Method Summary collapse

Constructor Details

#initializeBundleResolver

Returns a new instance of BundleResolver.



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

def initialize
  @classes = {}
end

Instance Method Details

#register_class(klass, bundle) ⇒ Object



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

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

#resolve_bundle(clazz) ⇒ Object



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

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

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