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
-
#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] end |
#before? ⇒ Boolean
31 32 33 |
# File 'lib/forwarder/arguments.rb', line 31 def before? before end |
#chain? ⇒ Boolean
35 36 37 |
# File 'lib/forwarder/arguments.rb', line 35 def chain? @params[ :to_chain ] end |
#complete_args(*args) ⇒ Object
39 40 41 |
# File 'lib/forwarder/arguments.rb', line 39 def complete_args *args (self.args || []) + args end |
#custom_target? ⇒ Boolean
43 44 45 |
# File 'lib/forwarder/arguments.rb', line 43 def custom_target? @params[:to_object] end |
#evaluable? ⇒ Boolean
def delegatable?
!aop? && !custom_target? && !all? && !chain? && !args && !lambda?
end
51 52 53 54 55 56 |
# File 'lib/forwarder/arguments.rb', line 51 def evaluable? !lambda? && !aop? && ( !args || args.all?{|a| Evaller.evaluable? a } ) && ( !custom_target? || Evaller.evaluable?( custom_target? ) ) end |
#lambda(default = nil) ⇒ Object
58 59 60 |
# File 'lib/forwarder/arguments.rb', line 58 def lambda default=nil lambda? || default end |
#lambda? ⇒ Boolean
62 63 64 |
# File 'lib/forwarder/arguments.rb', line 62 def lambda? @lambda end |
#must_not_compile? ⇒ Boolean
66 67 68 |
# File 'lib/forwarder/arguments.rb', line 66 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
72 73 74 75 |
# File 'lib/forwarder/arguments.rb', line 72 def object_target default return unless custom_target? target == :self ? default : target end |
#serialized_params ⇒ Object
77 78 79 |
# File 'lib/forwarder/arguments.rb', line 77 def serialized_params Evaller.serialize args end |
#to_hash? ⇒ Boolean
81 82 83 |
# File 'lib/forwarder/arguments.rb', line 81 def to_hash? @__to_hash__ ||= @params[ :to_hash ] end |
#translation(alternative = nil, &blk) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/forwarder/arguments.rb', line 85 def translation alternative=nil, &blk @params[ :as ].tap do | tltion | break alternative unless tltion break tltion unless blk blk.( tltion ) end end |