Module: Nitron::UI::ActionSupport

Included in:
ViewController
Defined in:
lib/nitron/ui/action_support.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/nitron/ui/action_support.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#_dispatch(sender) ⇒ Object



21
22
23
24
25
# File 'lib/nitron/ui/action_support.rb', line 21

def _dispatch(sender)
  if action = @_actions[sender]
    instance_eval &action[:handler]
  end
end

#deallocObject



27
28
29
30
31
# File 'lib/nitron/ui/action_support.rb', line 27

def dealloc
  @_actions.clear

  super
end

#viewDidLoadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/nitron/ui/action_support.rb', line 33

def viewDidLoad
  super

  @_actions = {}

  self.class.actions.each do |outlet, action|
    if respond_to?(outlet)
      target = send(outlet)
      @_actions[target] = self.class.actions[outlet]

      target.addTarget(self, action:"_dispatch:", forControlEvents:UIControlEventTouchUpInside)
    end
  end
end