Class: AngryMob::Target::Notify

Inherits:
Object
  • Object
show all
Defined in:
lib/angry_mob/target/notify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(act) ⇒ Notify

Returns a new instance of Notify.



7
8
9
10
11
12
13
14
15
16
# File 'lib/angry_mob/target/notify.rb', line 7

def initialize(act)
  @act = act

  @target = nil
  @args = AngryHash.new

  @actions = []

  @backtrace = caller
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &blk) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/angry_mob/target/notify.rb', line 36

def method_missing(method,*args,&blk)
  if ! @target
    @target = method.to_s
    @args = AngryHash.__convert_without_dup( args.first ) if args.first
  end

  if method == :now
    raise "notify.now is no longer supported"

  else
    @actions << method.to_s
  end

  return self
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



4
5
6
# File 'lib/angry_mob/target/notify.rb', line 4

def actions
  @actions
end

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/angry_mob/target/notify.rb', line 4

def args
  @args
end

#targetObject (readonly)

Returns the value of attribute target.



4
5
6
# File 'lib/angry_mob/target/notify.rb', line 4

def target
  @target
end

Instance Method Details

#call(mob) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/angry_mob/target/notify.rb', line 22

def call(mob)
  raise "not used anymore"
  args = Arguments.parse(@args)
  inject_actions(args)
  
  # localise to save into closure
  target = @target

  # this block is instance_eval'd
  @act.in_sub_act do
    send(target, args)
  end
end

#inject_actions(args) ⇒ Object



18
19
20
# File 'lib/angry_mob/target/notify.rb', line 18

def inject_actions(args)
  args.actions = @actions
end

#inspectObject



52
53
54
# File 'lib/angry_mob/target/notify.rb', line 52

def inspect
  "#<AM::T::Notify target=#{@target} actions=#{@actions.inspect}>"
end

#nicknameObject



5
# File 'lib/angry_mob/target/notify.rb', line 5

def nickname; @target end