module Mycrm::Domains::Rescuer
Public Instance Methods
[](label)
click to toggle source
# File lib/mycrm/domains.rb, line 5 def [](label) name = label.downcase.gsub(/\W/, '_') raise NameError, "#{label} is not a valid domain" unless constant?(name) create_constant(name) end
Also aliased as: find
Private Instance Methods
configured_domain()
click to toggle source
# File lib/mycrm/domains.rb, line 38 def configured_domain Mycrm.configuration.domains[self.name.split('::').last.to_underscore] end
const_missing(name)
click to toggle source
Calls superclass method
# File lib/mycrm/domains.rb, line 23 def const_missing(name) return super unless constant?(name) create_constant(name) end
constant?(name)
click to toggle source
# File lib/mycrm/domains.rb, line 34 def constant?(name) configured_domain && !configured_domain[name.to_underscore].nil? end
create_constant(name)
click to toggle source
# File lib/mycrm/domains.rb, line 28 def create_constant(name) configured_domain[name.to_underscore].tap do |val| self.const_set(name.to_camelized, val) unless self.const_defined?(name.to_camelized) end end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/mycrm/domains.rb, line 14 def method_missing(name, *args, &block) return super unless constant?(name) create_constant(name) end
respond_to_missing?(name, include_private = false)
click to toggle source
Calls superclass method
# File lib/mycrm/domains.rb, line 19 def respond_to_missing?(name, include_private = false) constant?(name) || super end