Class: BaseEditingBootstrap::ResourceFinder
- Inherits:
-
Object
- Object
- BaseEditingBootstrap::ResourceFinder
- Defined in:
- lib/base_editing_bootstrap/resource_finder.rb
Overview
PORO to find the base classe in the BaseEditingController
Instance Method Summary collapse
-
#initialize(controllar_path) ⇒ ResourceFinder
constructor
A new instance of ResourceFinder.
- #model ⇒ NilClass|Object
Constructor Details
#initialize(controllar_path) ⇒ ResourceFinder
Returns a new instance of ResourceFinder.
7 8 9 10 |
# File 'lib/base_editing_bootstrap/resource_finder.rb', line 7 def initialize(controllar_path) @controllar_path = controllar_path @_model_class = false end |
Instance Method Details
#model ⇒ NilClass|Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/base_editing_bootstrap/resource_finder.rb', line 13 def model if @_model_class === false @_model_class = nil if (anything = @controllar_path.singularize.camelize.safe_constantize) @_model_class = anything else if @controllar_path.include?("/") demodulize_one_level = @controllar_path.split("/")[1..].join("/") if demodulize_one_level != @controllar_path @_model_class = ResourceFinder.new(demodulize_one_level).model end end end end @_model_class end |