Sha256: ade248b76d5f190fd2cb347e983edb30816881d2df9af50d326e0f0a27eeb386
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
module CapybaraObjects class RegistryInstance include Singleton def initialize self.ctypes = HashWithIndifferentAccess.new self.ptypes = HashWithIndifferentAccess.new 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 def register_ctype(type, klass) ctypes[type] = klass end # @TODO Raise exceptions if ptype or ctype not found # # 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 def register_ptype(type, klass) ptypes[type] = klass end # Lookup a component object by its type # @param [String] ctype The component type to lookup # @return [Class] The registered class # @raise ::CapybaraObjects::Exceptions::TypeNotRegistered 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 def lookup_ptype(ptype) ptypes[ptype] or raise Exceptions::TypeNotRegistered.new(ptype) end private attr_accessor :ctypes, :ptypes end end
Version data entries
3 entries across 3 versions & 1 rubygems