Project

curryable

0.0
No commit activity in last 3 years
No release in over 3 years
Enables immutable command objects to act as currable functions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
= 0.10.1
~> 10.0
 Project Readme

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>:0x839fa96b9467e0 user_creator:User, email_api:#<EmailAPI>, crm_api:#<CRMAPI>, attributes:>

signup_service.call(
  attributes: user_attrs,
)

TODO

  • Contributing guide
  • List of features we would actively encourage
  • Code of conduct
  • Github badges
  • Travis
  • Code climate
  • Define supported Ruby versions and implementations
  • Test against all of them