Module: Resubject::Naming
- Defined in:
- lib/resubject/naming.rb
Class Method Summary collapse
-
.presenter_for(presentable) ⇒ Presenter
Discover the presenter class given the class name or string/symbol passed.
Class Method Details
.presenter_for(presentable) ⇒ Presenter
Discover the presenter class given the class name or string/symbol passed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/resubject/naming.rb', line 16 def self.presenter_for(presentable) klass = case presentable when Symbol presentable.to_s when String presentable else presentable.class.to_s end presenter = "#{klass.camelize}Presenter" # Gets each constant in the namespace presenter.split('::').inject(Object) { |ns, cons| ns.const_get(cons) } end |