Class: Locomotive::MenuCell
- Inherits:
-
Cell::Rails
- Object
- Cell::Rails
- Locomotive::MenuCell
- Defined in:
- app/cells/locomotive/menu_cell.rb
Direct Known Subclasses
Defined Under Namespace
Classes: MenuProxy
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ MenuCell
constructor
A new instance of MenuCell.
- #show(args = {}) ⇒ Object
- #url_options ⇒ Object
Constructor Details
#initialize(*args) ⇒ MenuCell
Returns a new instance of MenuCell.
10 11 12 13 |
# File 'app/cells/locomotive/menu_cell.rb', line 10 def initialize(*args) super self.list = [] end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
8 9 10 |
# File 'app/cells/locomotive/menu_cell.rb', line 8 def list @list end |
Class Method Details
.update_for(name, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/cells/locomotive/menu_cell.rb', line 40 def self.update_for(name, &block) method_name = "build_list_with_#{name}".to_sym previous_method_name = "build_list_without_#{name}".to_sym unless self.instance_methods.include?(method_name) # prevents the method to be called twice which will raise a "stack level too deep" exception self.send(:define_method, method_name) do self.send(previous_method_name) block.call(MenuProxy.new(self)) end # Note: this might cause "stack level too deep" if called twice for the same name alias_method_chain :build_list, name.to_sym end end |
Instance Method Details
#show(args = {}) ⇒ Object
15 16 17 18 |
# File 'app/cells/locomotive/menu_cell.rb', line 15 def show(args = {}) self.build_list render end |
#url_options ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/cells/locomotive/menu_cell.rb', line 20 def super.reverse_merge( :host => request.host_with_port, :protocol => request.protocol, :_path_segments => request.symbolized_path_parameters ).merge(:script_name => request.script_name) end |