Class: Forwarder::Arguments

Inherits:
Object
  • Object
show all
Defined in:
lib/forwarder/arguments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/forwarder/arguments.rb', line 3

def args
  @args
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/forwarder/arguments.rb', line 3

def message
  @message
end

#targetObject (readonly)

Returns the value of attribute target.



3
4
5
# File 'lib/forwarder/arguments.rb', line 3

def target
  @target
end

Instance Method Details

#afterObject



9
10
11
# File 'lib/forwarder/arguments.rb', line 9

def after
  @after ||= @params[:after]
end

#after?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/forwarder/arguments.rb', line 13

def after?
  after
end

#all?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/forwarder/arguments.rb', line 5

def all?
  !args? && !lambda? && @__all__
end

#aop?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/forwarder/arguments.rb', line 17

def aop?
  @__aop__ ||= !aop_values.empty?
end

#args?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/forwarder/arguments.rb', line 21

def args?
  !!args
end

#beforeObject



25
26
27
# File 'lib/forwarder/arguments.rb', line 25

def before
  @before ||= @params[:before]
end

#before?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/forwarder/arguments.rb', line 29

def before?
  before
end

#chain?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/forwarder/arguments.rb', line 33

def chain?
  @params[ :to_chain ]
end

#complete_args(*args) ⇒ Object



45
46
47
# File 'lib/forwarder/arguments.rb', line 45

def complete_args *args
  (self.args || []) + args
end

#custom_target?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/forwarder/arguments.rb', line 37

def custom_target?
  @params[:to_object]
end

#delegatable?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/forwarder/arguments.rb', line 41

def delegatable?
  !aop? && !custom_target? && !all? && !chain? && !args && !lambda?
end

#lambda(default = nil) ⇒ Object



49
50
51
# File 'lib/forwarder/arguments.rb', line 49

def lambda default=nil
  lambda? || default
end

#lambda?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/forwarder/arguments.rb', line 53

def lambda?
  @lambda
end

#object_target(default) ⇒ Object

This is always nil unless we are a custom_target, in which case default is returned if target is :self, else target is returned



59
60
61
62
# File 'lib/forwarder/arguments.rb', line 59

def object_target default
  return unless custom_target?
  target == :self ? default : target
end

#translation(alternative = nil, &blk) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/forwarder/arguments.rb', line 64

def translation alternative=nil, &blk
  @params[ :as ].tap do | tltion |
    break alternative unless tltion
    break tltion unless blk
    blk.( tltion ) 
  end
end