class CapybaraObjects::RegistryInstance

Attributes

ctypes[RW]
ptypes[RW]

Public Class Methods

new() click to toggle source
# File lib/capybara_objects/registry_instance.rb, line 4
def initialize
  self.ctypes = HashWithIndifferentAccess.new
  self.ptypes = HashWithIndifferentAccess.new
end

Public Instance Methods

lookup_ctype(ctype) click to toggle source

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_ptype(ptype) click to toggle source

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
register_ctype(type, klass) click to toggle source

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
register_ptype(type, klass) click to toggle source

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