Module: Phlex::Rails::HTML::MethodMissing

Defined in:
lib/phlex/rails/html/method_missing.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object

Raises:

  • (NoMethodError)


4
5
6
7
8
9
10
11
12
# File 'lib/phlex/rails/html/method_missing.rb', line 4

def method_missing(name, *args, **kwargs, &block)
	return super unless helpers.respond_to?(name)

	const_name = name.to_s.gsub("?", "")
	module_name = Phlex::Rails::Helpers.constants.find { |mod| mod.to_s.underscore.gsub("domid", "dom_id") == const_name }
	return super unless module_name

	raise NoMethodError.new("Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}.")
end