Class: CapybaraObjects::RegistryInstance
- Inherits:
-
Object
- Object
- CapybaraObjects::RegistryInstance
- Includes:
- Singleton
- Defined in:
- lib/capybara_objects/registry_instance.rb
Instance Method Summary collapse
-
#initialize ⇒ RegistryInstance
constructor
A new instance of RegistryInstance.
-
#lookup_ctype(ctype) ⇒ Class
Lookup a component object by its type.
-
#lookup_ptype(ptype) ⇒ Class
Lookup a page object by its type.
-
#register_ctype(type, klass) ⇒ Object
Registers a component class so an alias can be used rather than worrying about the module path etc..
-
#register_ptype(type, klass) ⇒ Object
Registers a page object class so an alias can be used rather than worrying about the module path etc..
Constructor Details
#initialize ⇒ RegistryInstance
Returns a new instance of RegistryInstance.
4 5 6 7 |
# File 'lib/capybara_objects/registry_instance.rb', line 4 def initialize self.ctypes = HashWithIndifferentAccess.new self.ptypes = HashWithIndifferentAccess.new end |
Instance Method Details
#lookup_ctype(ctype) ⇒ Class
Lookup a component object by its type
34 35 36 |
# File 'lib/capybara_objects/registry_instance.rb', line 34 def lookup_ctype(ctype) ctypes[ctype] or raise Exceptions::TypeNotRegistered.new(ctype) end |
#lookup_ptype(ptype) ⇒ Class
Lookup a page object by its type
42 43 44 |
# File 'lib/capybara_objects/registry_instance.rb', line 42 def lookup_ptype(ptype) ptypes[ptype] or raise Exceptions::TypeNotRegistered.new(ptype) end |
#register_ctype(type, klass) ⇒ Object
Registers a component class so an alias can be used rather than worrying about the module path etc..
14 15 16 |
# File 'lib/capybara_objects/registry_instance.rb', line 14 def register_ctype(type, klass) ctypes[type] = klass end |
#register_ptype(type, klass) ⇒ Object
Registers a page object class so an alias can be used rather than worrying about the module path etc..
26 27 28 |
# File 'lib/capybara_objects/registry_instance.rb', line 26 def register_ptype(type, klass) ptypes[type] = klass end |