Module: ConvenientService::Plugins

Defined in:
lib/convenient_service/common/plugins/aliases.rb,
lib/convenient_service/feature/plugins/aliases.rb,
lib/convenient_service/service/plugins/aliases.rb,
lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/aliases.rb,
lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/aliases.rb,
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/aliases.rb,
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/aliases.rb,
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/aliases.rb,
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/aliases.rb,
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/aliases.rb

Overview

Intermediate module/namespace to access plugins. See Constant Summary for examples.

Returns:

  • (Module)

Since:

  • 1.0.0

Constant Summary collapse

Common =

Intermediate module/namespace to access plugins that can be applied to several types of entities.

Examples:

Common plugin CanHaveCallbacks is used by both services and steps.

##
# Since the `CanHaveCallbacks` common plugin is included by default by the standard config,
# the example below shows how to remove it instead of adding it.
#
class Service
  include ConvenientService::Standard::Config

  concerns do
    delete ConvenientService::Plugins::Common::CanHaveCallbacks::Concern
  end

  middlewares :result do
    delete ConvenientService::Plugins::Common::CanHaveCallbacks::Middleware
  end

  entity :Step do
    concerns do
      delete ConvenientService::Plugins::Common::CanHaveCallbacks::Concern
    end

    middlewares :result do
      delete ConvenientService::Plugins::Common::CanHaveCallbacks::Middleware
    end
  end

  ##
  # Raises since `CanHaveCallbacks` is removed.
  #
  before :result do
  end

  def result
    success
  end
end

Shorter way to remove CanHaveCallbacks plugin.

##
# Some common plugin groups like `:callbacks` can be removed by config option.
#
class Service
  include ConvenientService::Standard::Config.without(:callbacks)

  ##
  # Raises since `CanHaveCallbacks` is removed.
  #
  before :result do
  end

  def result
    success
  end
end

Returns:

  • (Module)

Since:

  • 1.0.0

::ConvenientService::Common::Plugins
Feature =

Intermediate module/namespace to access plugins that can be applied only to features.

Examples:

Feature plugin CanHaveEntries is used for features.

##
# Since the `CanHaveEntries` feature plugin is included by default by the feature standard config,
# the example below shows how to remove it instead of adding it.
#
class Feature
  include ConvenientService::Feature::Standard::Config

  concerns do
    delete ConvenientService::Plugins::Feature::CanHaveEntries::Concern
  end

  ##
  # Raises since `CanHaveEntries` is removed.
  #
  entry :main

  def main
    :main_entry_value
  end
end

Returns:

  • (Module)

Since:

  • 1.0.0

::ConvenientService::Feature::Plugins
Service =

Intermediate module/namespace to access plugins that can be applied only to services.

Examples:

Service plugin CanHaveRollbacks can be used only by services.

class Service
  include ConvenientService::Standard::Config

  middlewares :result do
    insert_after \
      ConvenientService::Plugins::Common::CanHaveCallbacks::Middleware,
      ConvenientService::Plugins::Service::CanHaveRollbacks::Middleware
  end

  def result
    success
  end

  ##
  # Is called in case of `failure` or `error` from `result`, since `CanHaveRollbacks` is now enabled.
  #
  def rollback_result
    puts "from `rollback_result`"
  end
end

Shorter way to add CanHaveRollbacks plugin.

##
# Some service plugin groups like `:rollbacks` can be added by config option.
#
class Service
  include ConvenientService::Standard::Config.with(:rollbacks)

  def result
    success
  end

  ##
  # Is called in case of `failure` or `error` from `result`, since `CanHaveRollbacks` is now enabled.
  #
  def rollback_result
    puts "from `rollback_result`"
  end
end

Returns:

  • (Module)

Since:

  • 1.0.0

::ConvenientService::Service::Plugins
Step =

Since:

  • 1.0.0

::ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins
Internals =

Since:

  • 1.0.0

::ConvenientService::Common::Plugins::HasInternals::Entities::Internals::Plugins
Result =

Since:

  • 1.0.0

::ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins
Code =

Since:

  • 1.0.0

::ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Plugins
Data =

Since:

  • 1.0.0

::ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Plugins
Status =

Since:

  • 1.0.0

::ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status::Plugins
Message =

Since:

  • 1.0.0

::ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins