Class: Bparity::Adapter::Operation
- Inherits:
-
Struct
- Object
- Struct
- Bparity::Adapter::Operation
- Defined in:
- lib/bparity/adapter.rb
Instance Attribute Summary collapse
-
#error_mapper ⇒ Object
Returns the value of attribute error_mapper.
-
#invoker ⇒ Object
Returns the value of attribute invoker.
-
#name ⇒ Object
Returns the value of attribute name.
-
#return_mapper ⇒ Object
Returns the value of attribute return_mapper.
Instance Method Summary collapse
- #invoke(subject, args, kwargs, &block) ⇒ Object
- #map_error(error) ⇒ Object
- #map_return(value) ⇒ Object
Instance Attribute Details
#error_mapper ⇒ Object
Returns the value of attribute error_mapper
7 8 9 |
# File 'lib/bparity/adapter.rb', line 7 def error_mapper @error_mapper end |
#invoker ⇒ Object
Returns the value of attribute invoker
7 8 9 |
# File 'lib/bparity/adapter.rb', line 7 def invoker @invoker end |
#name ⇒ Object
Returns the value of attribute name
7 8 9 |
# File 'lib/bparity/adapter.rb', line 7 def name @name end |
#return_mapper ⇒ Object
Returns the value of attribute return_mapper
7 8 9 |
# File 'lib/bparity/adapter.rb', line 7 def return_mapper @return_mapper end |
Instance Method Details
#invoke(subject, args, kwargs, &block) ⇒ Object
8 9 10 11 12 |
# File 'lib/bparity/adapter.rb', line 8 def invoke(subject, args, kwargs, &block) return invoker.call(subject, args, kwargs, &block) if invoker subject.public_send(name.delete_prefix("#"), *args, **kwargs, &block) end |
#map_error(error) ⇒ Object
16 17 18 |
# File 'lib/bparity/adapter.rb', line 16 def map_error(error) error_mapper ? error_mapper.call(error) : { class: error.class.name, message: Bparity.(error) } end |
#map_return(value) ⇒ Object
14 |
# File 'lib/bparity/adapter.rb', line 14 def map_return(value) = return_mapper ? return_mapper.call(value) : value |