Class: IronNails::Core::ComponentRegistry
- Inherits:
-
Object
- Object
- IronNails::Core::ComponentRegistry
- Defined in:
- lib/ironnails/nails_engine.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
Returns the value of attribute components.
Instance Method Summary collapse
- #find_controller(controller) ⇒ Object
-
#initialize ⇒ ComponentRegistry
constructor
A new instance of ComponentRegistry.
- #register(controller) ⇒ Object
- #register_view_for(controller, view) ⇒ Object
- #register_viewmodel_for(controller, model) ⇒ Object
- #view_for(controller) ⇒ Object
- #viewmodel_for(controller) ⇒ Object
Constructor Details
#initialize ⇒ ComponentRegistry
Returns a new instance of ComponentRegistry.
240 241 242 |
# File 'lib/ironnails/nails_engine.rb', line 240 def initialize @components = {} end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components.
238 239 240 |
# File 'lib/ironnails/nails_engine.rb', line 238 def components @components end |
Instance Method Details
#find_controller(controller) ⇒ Object
256 257 258 259 |
# File 'lib/ironnails/nails_engine.rb', line 256 def find_controller(controller) con_name = controller.respond_to?(:controller_name) ? controller.controller_name : controller.to_sym components[con_name] end |
#register(controller) ⇒ Object
244 245 246 |
# File 'lib/ironnails/nails_engine.rb', line 244 def register(controller) components[controller.controller_name] = ComponentRegistryItem.new end |
#register_view_for(controller, view) ⇒ Object
248 249 250 |
# File 'lib/ironnails/nails_engine.rb', line 248 def register_view_for(controller, view) find_controller(controller).view = view end |
#register_viewmodel_for(controller, model) ⇒ Object
252 253 254 |
# File 'lib/ironnails/nails_engine.rb', line 252 def register_viewmodel_for(controller, model) find_controller(controller).viewmodel = model end |
#view_for(controller) ⇒ Object
265 266 267 |
# File 'lib/ironnails/nails_engine.rb', line 265 def view_for(controller) find_controller(controller).view end |
#viewmodel_for(controller) ⇒ Object
261 262 263 |
# File 'lib/ironnails/nails_engine.rb', line 261 def viewmodel_for(controller) find_controller(controller).viewmodel end |