Hi I have two modules
Admin.is_engine?
=> false
Blog.is_engine?
=> true
Definately I can have a try catch thing to determine this
def is_engine? module
module::Engine
true
rescue NameError
false
end
here
is_engine? Admin
will return false
is_engine? Blog
will return true
Thanks
I'm not sure I understand what you are trying to do: a Rails Engine is a class (a subclass of Rails::Engine
), not a module.
If you have an instance, you could use:
admin.kind_of?(Rails::Engine)
If you have a class, you can use:
Something.ancestors.include?(Rails::Engine)
If what you have is a module, then it cannot be a subclass of Rails::Engine, and it's not an engine.
If you have a module or constant something
and want to know if there's a constant with a certain name in its namespace, you can use:
something.constants.include?(:Engine)