Class: Bread::ControllerLayoutCommand
- Inherits:
-
Object
- Object
- Bread::ControllerLayoutCommand
- Defined in:
- lib/bread/commands/controller_layout_command.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #actions(*action_names, &block) ⇒ Object
- #crumbs(*keys) ⇒ Object
-
#initialize(controller) ⇒ ControllerLayoutCommand
constructor
A new instance of ControllerLayoutCommand.
Constructor Details
#initialize(controller) ⇒ ControllerLayoutCommand
Returns a new instance of ControllerLayoutCommand.
6 7 8 9 10 11 12 13 14 |
# File 'lib/bread/commands/controller_layout_command.rb', line 6 def initialize(controller) IvarsCommand.new(controller).ivars.each do |key, ivar| self.instance_variable_set(key, ivar) end @controller = controller @actions = {} @keys = [] end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
4 5 6 |
# File 'lib/bread/commands/controller_layout_command.rb', line 4 def keys @keys end |
Instance Method Details
#actions(*action_names, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bread/commands/controller_layout_command.rb', line 16 def actions(*action_names, &block) action_names.each do |action_name| @actions[action_name] = block is_current_action = action_name.to_s == @controller.action_name if is_current_action self.instance_eval(&block) # teria que ter um break aqui, que tambem pare todos os registros de proximas actions =D end end end |
#crumbs(*keys) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bread/commands/controller_layout_command.rb', line 28 def crumbs(*keys) parent = nil if keys.last.is_a? Hash = keys.last keys.delete() #raise "Unexpected options: #{}" parent = [:parent] end @keys = keys + @keys if parent blk = @actions[parent] instance_eval(&blk) end end |