Socket
Book a DemoInstallSign in
Socket

curryable

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curryable

0.1.1
bundlerRubygems
Version published
Maintainers
2
Created
Source

Curryable

## What is a command object?

An object (noun) that acts as a container for a function (verb).

Design goals

  • Objects should be immutable
  • Object should act like a function
  • Arguments to the object can be curried
  • Objects should be inspectable. Inspection should reveal
    • the class
    • which arguments have been curried, and their values
class SignUpUser
  def initialize(user_creator:, attributes:, email_api:, crm_api:)
    @user_creator = user_creator
    @attributes = attributes
    @email_api = email_api
    @crm_api = crm_api
  end

  attr_reader :user_creator, :attributes, :email_api, :crm_api
  private     :user_creator, :attributes, :email_api, :crm_api

  def call
    create_user_record
    send_confirmation_email
    add_user_to_crm
  end
end

signup_service = Curryable.new(SignUpUser).call(
  user_creator: User,
  email_api: EmailAPI.new(EMAIL_AUTH_TOKEN),
  crm_api: CRMAPI.new(CRM_AUTH_TOKEN),
)

signup_service.inspect
# => <# Curryable<SignUpUser> user_creator=User, email_api=<#EmailAPI>, crm_api=<#CRMAPI>, attributes=>

signup_service.call(
  attributes: user_attrs,
)

FAQs

Package last updated on 09 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.