Module: ConvenientService::Service::Configs::Standard

Includes:
Config, ConvenientService::Service::Core
Included in:
Examples::Standard::Cowsay::Services::BuildCloud, Examples::Standard::Cowsay::Services::BuildCow, Examples::Standard::Cowsay::Services::Print, Examples::Standard::DateTime::Services::SafeParse, Examples::Standard::Factorial::Services::Calculate, Examples::Standard::Gemfile::Services::AssertFileExists, Examples::Standard::Gemfile::Services::AssertFileNotEmpty, Examples::Standard::Gemfile::Services::AssertNodeAvailable, Examples::Standard::Gemfile::Services::AssertNpmPackageAvailable, Examples::Standard::Gemfile::Services::AssertValidRubySyntax, Examples::Standard::Gemfile::Services::Format, Examples::Standard::Gemfile::Services::FormatBody, Examples::Standard::Gemfile::Services::FormatGemsWithEnvs, Examples::Standard::Gemfile::Services::FormatGemsWithoutEnvs, Examples::Standard::Gemfile::Services::FormatHeader, Examples::Standard::Gemfile::Services::MergeSections, Examples::Standard::Gemfile::Services::ParseContent, Examples::Standard::Gemfile::Services::PrintShellCommand, Examples::Standard::Gemfile::Services::ReadFileContent, Examples::Standard::Gemfile::Services::ReplaceFileContent, Examples::Standard::Gemfile::Services::RunShellCommand, Examples::Standard::Gemfile::Services::StripComments, Examples::Standard::RequestParams::Services::ApplyDefaultParamValues, Examples::Standard::RequestParams::Services::CastParams, Examples::Standard::RequestParams::Services::ExtractParamsFromBody, Examples::Standard::RequestParams::Services::ExtractParamsFromPath, Examples::Standard::RequestParams::Services::FilterOutUnpermittedParams, Examples::Standard::RequestParams::Services::LogRequestParams, Examples::Standard::RequestParams::Services::MergeParams, Examples::Standard::RequestParams::Services::Prepare, Examples::Standard::RequestParams::Services::ValidateCastedParams, Examples::Standard::RequestParams::Services::ValidateUncastedParams
Defined in:
lib/convenient_service/service/configs/standard.rb,
lib/convenient_service/service/configs/standard/v1.rb

Overview

Default configuration for the user-defined services.

Defined Under Namespace

Modules: V1

Class Method Summary collapse

Methods included from Core

entity?, entity_class?

Methods included from Config

empty_options, included

Class Method Details

.service?(service) ⇒ Boolean

Checks whether an object is a service instance.

Examples:

Simple usage.

class Service
  include ConvenientService::Standard::Config

  def result
    success
  end
end

ConvenientService::Service::Configs::Standard.service?(Service.new)
# => true

ConvenientService::Service::Configs::Standard.service?(Service)
# => false

ConvenientService::Service::Configs::Standard.service?(42)
# => false

Parameters:

  • service (Object)

    Can be any type.

Returns:

  • (Boolean)


424
425
426
# File 'lib/convenient_service/service/configs/standard.rb', line 424

def service?(service)
  service_class?(service.class)
end

.service_class?(service_class) ⇒ Boolean

Checks whether a class is a service class.

Examples:

Simple usage.

class Service
  include ConvenientService::Standard::Config

  def result
    success
  end
end

ConvenientService::Service::Configs::Standard.service_class?(Service)
# => true

ConvenientService::Service::Configs::Standard.service_class?(Service.new)
# => false

ConvenientService::Service::Configs::Standard.service_class?(42)
# => false

Parameters:

  • service_class (Object)

    Can be any type.

Returns:

  • (Boolean)


392
393
394
395
396
# File 'lib/convenient_service/service/configs/standard.rb', line 392

def service_class?(service_class)
  return false unless service_class.instance_of?(::Class)

  service_class.include?(Service::Core)
end