Module: Charming::Controller::FocusManagement
- Included in:
- Charming::Controller
- Defined in:
- lib/charming/controller/focus_management.rb
Overview
Focus helpers mixed into Controller: lazily-allocated per-controller Focus object and predicates for ‘focused?(:slot)` checks from views. The Focus object is keyed by controller class name in the session, so it survives across controller dispatches for the same class.
Instance Method Summary collapse
-
#focus ⇒ Object
Returns the per-controller Focus object, defining the focus ring from class-level DSL declarations on first access.
-
#focused?(slot) ⇒ Boolean
Returns true when the named slot is the currently focused slot in this controller’s focus ring.
Instance Method Details
#focus ⇒ Object
Returns the per-controller Focus object, defining the focus ring from class-level DSL declarations on first access.
11 12 13 14 15 |
# File 'lib/charming/controller/focus_management.rb', line 11 def focus @focus ||= Focus.for(session, self.class).tap do |f| f.define(self.class.focus_ring_slots) unless self.class.focus_ring_slots.empty? end end |
#focused?(slot) ⇒ Boolean
Returns true when the named slot is the currently focused slot in this controller’s focus ring.
18 19 20 |
# File 'lib/charming/controller/focus_management.rb', line 18 def focused?(slot) focus.focused?(slot) end |