Class: Bparity::Adapter::Operation

Inherits:
Struct
  • Object
show all
Defined in:
lib/bparity/adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#error_mapperObject

Returns the value of attribute error_mapper

Returns:

  • (Object)

    the current value of error_mapper



7
8
9
# File 'lib/bparity/adapter.rb', line 7

def error_mapper
  @error_mapper
end

#invokerObject

Returns the value of attribute invoker

Returns:

  • (Object)

    the current value of invoker



7
8
9
# File 'lib/bparity/adapter.rb', line 7

def invoker
  @invoker
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/bparity/adapter.rb', line 7

def name
  @name
end

#return_mapperObject

Returns the value of attribute return_mapper

Returns:

  • (Object)

    the current value of 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.exception_message(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