class CapybaraObjects::RegistryInstance
Attributes
Public Class Methods
# File lib/capybara_objects/registry_instance.rb, line 4 def initialize self.ctypes = HashWithIndifferentAccess.new self.ptypes = HashWithIndifferentAccess.new end
Public Instance Methods
Lookup a component object by its type @param [String] ctype The component type to lookup @return [Class] The registered class @raise ::CapybaraObjects::Exceptions::TypeNotRegistered
# File lib/capybara_objects/registry_instance.rb, line 34 def lookup_ctype(ctype) ctypes[ctype] or raise Exceptions::TypeNotRegistered.new(ctype) end
Lookup a page object by its type @param [String] ptype The page object type to lookup @return [Class] The registered class @raise ::CapybaraObjects::Exceptions::TypeNotRegistered
# File lib/capybara_objects/registry_instance.rb, line 42 def lookup_ptype(ptype) ptypes[ptype] or raise Exceptions::TypeNotRegistered.new(ptype) end
Registers a component class so an alias can be used rather than worrying about the module path etc.. @param [String] type The type of component to register @param [Class] klass The class to register
# File lib/capybara_objects/registry_instance.rb, line 14 def register_ctype(type, klass) ctypes[type] = klass end
Registers a page object class so an alias can be used rather than worrying about the module path etc.. @param [String] type The type of page object to register @param [Class] klass The class to register @raise ::CapybaraObjects::Exceptions::UnregisteredType
# File lib/capybara_objects/registry_instance.rb, line 26 def register_ptype(type, klass) ptypes[type] = klass end