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
- #before_with_block? ⇒ Boolean
- #chain? ⇒ Boolean
- #complete_args(*args) ⇒ Object
- #custom_target? ⇒ Boolean
-
#evaluable? ⇒ Boolean
def delegatable? !aop? && !custom_target? && !all? && !chain? && !args && !lambda? end.
- #lambda(default = nil) ⇒ Object
- #lambda? ⇒ Boolean
- #must_not_compile? ⇒ 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.
- #serialized_params ⇒ Object
- #to_hash? ⇒ Boolean
- #translation(alternative = nil, &blk) ⇒ Object
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/forwarder/arguments.rb', line 5 def args @args end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/forwarder/arguments.rb', line 5 def @message end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/forwarder/arguments.rb', line 5 def target @target end |
Instance Method Details
#after ⇒ Object
11 12 13 |
# File 'lib/forwarder/arguments.rb', line 11 def after @after ||= @params[:after] end |
#after? ⇒ Boolean
15 16 17 |
# File 'lib/forwarder/arguments.rb', line 15 def after? after end |
#all? ⇒ Boolean
7 8 9 |
# File 'lib/forwarder/arguments.rb', line 7 def all? !args? && !lambda? && @__all__ end |
#aop? ⇒ Boolean
19 20 21 |
# File 'lib/forwarder/arguments.rb', line 19 def aop? @__aop__ ||= !aop_values.empty? end |
#args? ⇒ Boolean
23 24 25 |
# File 'lib/forwarder/arguments.rb', line 23 def args? !!args end |
#before ⇒ Object
27 28 29 |
# File 'lib/forwarder/arguments.rb', line 27 def before @before ||= @params[:before] || @params[:before_with_block] end |
#before? ⇒ Boolean
31 32 33 |
# File 'lib/forwarder/arguments.rb', line 31 def before? before end |
#before_with_block? ⇒ Boolean
35 36 37 |
# File 'lib/forwarder/arguments.rb', line 35 def before_with_block? !!@params[:before_with_block] end |
#chain? ⇒ Boolean
40 41 42 |
# File 'lib/forwarder/arguments.rb', line 40 def chain? @params[ :to_chain ] end |
#complete_args(*args) ⇒ Object
44 45 46 |
# File 'lib/forwarder/arguments.rb', line 44 def complete_args *args (self.args || []) + args end |
#custom_target? ⇒ Boolean
48 49 50 |
# File 'lib/forwarder/arguments.rb', line 48 def custom_target? @params[:to_object] end |
#evaluable? ⇒ Boolean
def delegatable?
!aop? && !custom_target? && !all? && !chain? && !args && !lambda?
end
56 57 58 59 60 61 |
# File 'lib/forwarder/arguments.rb', line 56 def evaluable? !lambda? && !aop? && ( !args || args.all?{|a| Evaller.evaluable? a } ) && ( !custom_target? || Evaller.evaluable?( custom_target? ) ) end |
#lambda(default = nil) ⇒ Object
63 64 65 |
# File 'lib/forwarder/arguments.rb', line 63 def lambda default=nil lambda? || default end |
#lambda? ⇒ Boolean
67 68 69 |
# File 'lib/forwarder/arguments.rb', line 67 def lambda? @lambda end |
#must_not_compile? ⇒ Boolean
71 72 73 |
# File 'lib/forwarder/arguments.rb', line 71 def must_not_compile? lambda? || aop? || custom_target? 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
77 78 79 80 |
# File 'lib/forwarder/arguments.rb', line 77 def object_target default return unless custom_target? target == :self ? default : target end |
#serialized_params ⇒ Object
82 83 84 |
# File 'lib/forwarder/arguments.rb', line 82 def serialized_params Evaller.serialize args end |
#to_hash? ⇒ Boolean
86 87 88 |
# File 'lib/forwarder/arguments.rb', line 86 def to_hash? @__to_hash__ ||= @params[ :to_hash ] end |
#translation(alternative = nil, &blk) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/forwarder/arguments.rb', line 90 def translation alternative=nil, &blk @params[ :as ].tap do | tltion | break alternative unless tltion break tltion unless blk blk.( tltion ) end end |