Class: Seatbelt::Eigenmethod
- Inherits:
-
Object
- Object
- Seatbelt::Eigenmethod
- Defined in:
- lib/seatbelt/core/eigenmethod.rb
Overview
Public: A configuration class that contains the implementation method directives and attributes.
Instance Attribute Summary collapse
-
#arity ⇒ Object
Returns the value of attribute arity.
-
#delegated ⇒ Object
Returns the value of attribute delegated.
-
#implemented_as ⇒ Object
Returns the value of attribute implemented_as.
-
#method ⇒ Object
Returns the value of attribute method.
-
#method_implementation_type ⇒ Object
Returns the value of attribute method_implementation_type.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#receiver ⇒ Object
Public: The receiver of the implementation method.
-
#scope_level ⇒ Object
(also: #scope)
Returns the value of attribute scope_level.
Instance Method Summary collapse
- #[](attr) ⇒ Object
-
#call(*args, &block) ⇒ Object
Public: Calls the implementation method of an API method call.
-
#class_level? ⇒ Boolean
Implementation type at remote class (API class) side.
-
#class_method_implementation? ⇒ Boolean
Implementation type at the implementation class side.
-
#init_klass_on_receiver(klass_object) ⇒ Object
Creates the corrosponding class on the receiver and defines the proxy tunnel on the receivers proxy object.
-
#instance_level? ⇒ Boolean
Implementation type at remote class (API class) side.
-
#instance_method_implementation? ⇒ Boolean
Implementation type at the implementation class side.
Instance Attribute Details
#arity ⇒ Object
Returns the value of attribute arity.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def arity @arity end |
#delegated ⇒ Object
Returns the value of attribute delegated.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def delegated @delegated end |
#implemented_as ⇒ Object
Returns the value of attribute implemented_as.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def implemented_as @implemented_as end |
#method ⇒ Object
Returns the value of attribute method.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def method @method end |
#method_implementation_type ⇒ Object
Returns the value of attribute method_implementation_type.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def method_implementation_type @method_implementation_type end |
#namespace ⇒ Object
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def namespace @namespace end |
#receiver ⇒ Object
Public: The receiver of the implementation method. This is always an instance whether it defines a class method or instance method implementation.
Returns receivers instance.
23 24 25 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 23 def receiver @receiver end |
#scope_level ⇒ Object Also known as: scope
Returns the value of attribute scope_level.
7 8 9 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 7 def scope_level @scope_level end |
Instance Method Details
#[](attr) ⇒ Object
68 69 70 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 68 def [](attr) self.send(attr) end |
#call(*args, &block) ⇒ Object
Public: Calls the implementation method of an API method call.
*args - argument list for the implementation method. &block - A block if needed.
Returns the evaluated value.
63 64 65 66 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 63 def call(*args, &block) return __send_class_level(*args, &block) if class_level? return __send_instance_level(*args, &block) if instance_level? end |
#class_level? ⇒ Boolean
Implementation type at remote class (API class) side.
Returns true if a class method is implemented, otherwise false.
38 39 40 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 38 def class_level? not self.instance_level? end |
#class_method_implementation? ⇒ Boolean
Implementation type at the implementation class side.
Returns true if a class method is implemented, otherwise false.
45 46 47 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 45 def class_method_implementation? self.method_implementation_type.eql?(:class) end |
#init_klass_on_receiver(klass_object) ⇒ Object
Creates the corrosponding class on the receiver and defines the proxy tunnel on the receivers proxy object.
klass_object - The API Class or an instance of the API class.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 82 def init_klass_on_receiver(klass_object) if instance_level? __generate_proxy_object(@callee, klass_object) end if class_level? if class_method_implementation? __generate_proxy_object(receiver, klass_object) else if method_implementation_type.eql?(:instance) @callee = callee.new if @callee.respond_to?(:new) @callee.instance_variable_set(:@proxy,Seatbelt::Proxy.new) __generate_proxy_object(callee, klass_object) end end end end |
#instance_level? ⇒ Boolean
Implementation type at remote class (API class) side.
Returns true if an instance method is implemented, otherwise false.
31 32 33 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 31 def instance_level? self.scope_level.eql?(:instance) end |
#instance_method_implementation? ⇒ Boolean
Implementation type at the implementation class side.
Returns true if an instance method is implemented, otherwise false.
52 53 54 |
# File 'lib/seatbelt/core/eigenmethod.rb', line 52 def instance_method_implementation? not class_method_implementation? end |