Class: IronNails::View::EventCommand

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

Overview

Encapsulates commands that will be attached to elements in the views.

Instance Attribute Summary collapse

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, #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

#affinityObject

the name of the on which this command needs to be invoked



15
16
17
# File 'lib/ironnails/view/commands/event_command.rb', line 15

def affinity
  @affinity
end

#elementObject

the name of the element that will trigger the action



12
13
14
# File 'lib/ironnails/view/commands/event_command.rb', line 12

def element
  @element
end

#triggerObject

the name of the event that will trigger the action



9
10
11
# File 'lib/ironnails/view/commands/event_command.rb', line 9

def trigger
  @trigger
end

Instance Method Details

#nails_base_command_read_optionsObject



17
# File 'lib/ironnails/view/commands/event_command.rb', line 17

alias_method :nails_base_command_read_options, :read_options

#read_options(options) ⇒ Object

Raises:

  • (ArgumentException)


19
20
21
22
23
24
25
26
# File 'lib/ironnails/view/commands/event_command.rb', line 19

def read_options(options)
  nails_base_command_read_options options
  raise ArgumentException.new("An element name is necesary") if options[:element].nil?

  @trigger = options[:event]||:click
  @element = options[:element]
  @affinity = options[:affinity]
end