Class: IronNails::View::AddSubViewCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ironnails/view/commands/add_sub_view_command.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#action, #callback, #condition, #mode, #name, #view

Instance Method Summary collapse

Methods inherited from Command

#<=>, #==, #asynchronous?, #attached?, #can_execute?, #changed?, #has_callback?, #initialize, #refresh_view, #synchronise_viewmodel_with_controller

Methods included from Core::Observable

#add_observer, #count_observers, #delete_observer, #delete_observers, #notify_observers

Methods included from Logging::ClassLogger

#log_on_error, #logger

Constructor Details

This class inherits a constructor from IronNails::View::Command

Instance Attribute Details

#controllerObject

the controller for the subview



8
9
10
# File 'lib/ironnails/view/commands/add_sub_view_command.rb', line 8

def controller
  @controller
end

#targetObject

the target that will contain the view for this controller



11
12
13
# File 'lib/ironnails/view/commands/add_sub_view_command.rb', line 11

def target
  @target
end

Instance Method Details

#executeObject

executes this command (it calls the action)



25
26
27
# File 'lib/ironnails/view/commands/add_sub_view_command.rb', line 25

def execute
  view.add_control target, controller.current_view.instance
end

#nails_base_command_read_optionsObject



13
# File 'lib/ironnails/view/commands/add_sub_view_command.rb', line 13

alias_method :nails_base_command_read_options, :read_options

#read_options(options) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
# File 'lib/ironnails/view/commands/add_sub_view_command.rb', line 15

def read_options(options)
  nails_base_command_read_options options
  raise ArgumentError.new("We need a target to be defined by the :to parameter") if options[:to].nil?
  raise ArgumentError.new("We need a controller instance to be defined in the :controller parameter") if options[:controller].nil? || !options[:controller].respond_to?(:current_view)

  @controller = options[:controller]
  @target = options[:to]
end