Class: Lowkey::MethodProxy
- Includes:
- Query
- Defined in:
- lib/proxies/method_proxy.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#return_proxy ⇒ Object
readonly
Returns the value of attribute return_proxy.
Attributes inherited from Proxy
Instance Method Summary collapse
- #[](key) ⇒ Object
- #expressions? ⇒ Boolean
-
#initialize(name:, source:, param_proxies: [], body_proxy: nil, return_proxy: nil) ⇒ MethodProxy
constructor
A new instance of MethodProxy.
- #params_with_expressions ⇒ Object
- #tagged_params(tag) ⇒ Object
Methods included from Query
Constructor Details
#initialize(name:, source:, param_proxies: [], body_proxy: nil, return_proxy: nil) ⇒ MethodProxy
Returns a new instance of MethodProxy.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/proxies/method_proxy.rb', line 12 def initialize(name:, source:, param_proxies: [], body_proxy: nil, return_proxy: nil) super(name:, source:) @params = param_proxies @body = body_proxy @return_proxy = return_proxy @named_params = name_params @tagged_params = tag_params end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/proxies/method_proxy.rb', line 10 def body @body end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/proxies/method_proxy.rb', line 10 def params @params end |
#return_proxy ⇒ Object (readonly)
Returns the value of attribute return_proxy.
10 11 12 |
# File 'lib/proxies/method_proxy.rb', line 10 def return_proxy @return_proxy end |
Instance Method Details
#[](key) ⇒ Object
23 24 25 26 |
# File 'lib/proxies/method_proxy.rb', line 23 def [](key) # TODO: Initialize method proxy with method node and support query code path. key.start_with?('.') ? query(node: @node, namespace: nil, name: key.delete_prefix('.')) : @named_params[key] end |
#expressions? ⇒ Boolean
32 33 34 |
# File 'lib/proxies/method_proxy.rb', line 32 def expressions? @params.any?(&:expression) || @return_proxy end |
#params_with_expressions ⇒ Object
36 37 38 |
# File 'lib/proxies/method_proxy.rb', line 36 def params_with_expressions @params_with_expressions ||= @params.filter(&:expression) end |
#tagged_params(tag) ⇒ Object
28 29 30 |
# File 'lib/proxies/method_proxy.rb', line 28 def tagged_params(tag) @tagged_params[tag] || [] end |