Class: Forwarder::Arguments
- Inherits:
-
Object
- Object
- Forwarder::Arguments
- Defined in:
- lib/forwarder/arguments.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #after ⇒ Object
- #after? ⇒ Boolean
- #all? ⇒ Boolean
- #aop? ⇒ Boolean
- #args? ⇒ Boolean
- #before ⇒ Object
- #before? ⇒ Boolean
- #chain? ⇒ Boolean
- #complete_args(*args) ⇒ Object
- #custom_target? ⇒ Boolean
- #delegatable? ⇒ Boolean
- #lambda(default = nil) ⇒ Object
- #lambda? ⇒ Boolean
-
#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.
- #translation(alternative = nil, &blk) ⇒ Object
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/forwarder/arguments.rb', line 3 def args @args end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/forwarder/arguments.rb', line 3 def @message end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
3 4 5 |
# File 'lib/forwarder/arguments.rb', line 3 def target @target end |
Instance Method Details
#after ⇒ Object
9 10 11 |
# File 'lib/forwarder/arguments.rb', line 9 def after @after ||= @params[:after] end |
#after? ⇒ Boolean
13 14 15 |
# File 'lib/forwarder/arguments.rb', line 13 def after? after end |
#all? ⇒ Boolean
5 6 7 |
# File 'lib/forwarder/arguments.rb', line 5 def all? !args? && !lambda? && @__all__ end |
#aop? ⇒ Boolean
17 18 19 |
# File 'lib/forwarder/arguments.rb', line 17 def aop? @__aop__ ||= !aop_values.empty? end |
#args? ⇒ Boolean
21 22 23 |
# File 'lib/forwarder/arguments.rb', line 21 def args? !!args end |
#before ⇒ Object
25 26 27 |
# File 'lib/forwarder/arguments.rb', line 25 def before @before ||= @params[:before] end |
#before? ⇒ Boolean
29 30 31 |
# File 'lib/forwarder/arguments.rb', line 29 def before? before end |
#chain? ⇒ 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
37 38 39 |
# File 'lib/forwarder/arguments.rb', line 37 def custom_target? @params[:to_object] end |
#delegatable? ⇒ 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
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 |