Class: IronNails::View::BehaviorCommand

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

Instance Attribute Summary

Attributes inherited from Command

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

Instance Method Summary collapse

Methods inherited from Command

#<=>, #==, #asynchronous?, #attached?, #can_execute?, #changed?, #execute, #has_callback?, #initialize, #read_options, #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 Method Details

#async_delegate_commandObject



22
23
24
# File 'lib/ironnails/view/commands/behavior_command.rb', line 22

def async_delegate_command
  IronNails::Library::AsynchronousDelegateCommand
end

#delegate_commandObject



18
19
20
# File 'lib/ironnails/view/commands/behavior_command.rb', line 18

def delegate_command
  IronNails::Library::DelegateCommand
end

#to_clr_commandObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/ironnails/view/commands/behavior_command.rb', line 7

def to_clr_command
  # I have to wrap the method calls into blocks because .to_proc hasn't been implemented yet on method
  # the Func's have to be wrapped in lambda's to preserve the return statement.
  unless asynchronous?
    delegate_command.new(Action.new { execute }, Func[System::Boolean].new(&lambda{ can_execute? } ))
  else
    async_delegate_command.new(Action.new { execute }, Action.new { refresh_view },
                               Func[System::Boolean].new(&lambda{ can_execute? }))
  end
end