Socket
Book a DemoInstallSign in
Socket

transmute

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transmute

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Transmute

a framework for writing functional helpers in ruby

Installation

gem 'transmute'

Usage

require 'transmute'

# Transmute provides a very light weight framework for definining
# helpers in a functional, chainable manner
#
# To define a function, simply add an instance method to Transmute::Definition

Transmute::Definition.module_eval do
  def increment(value, n = 1)
    value + n
  end
end

# The methods you add to Transmute::Definition can then be used via the Transmute
# module

[1, 2, 3].map(&Transmute.increment)
#=> [2, 3, 4]

[1, 2, 3].map(&Transmute.increment).map(&Transmute.increment)
#=> [3, 4, 5]

[1, 2, 3].map(&Transmute.increment(2))
#=> [3, 4, 5]

TODO

  • support some pattern matching-esque format (e.g.
on Integer
def increment(value, n = 1)
  value + n
end

on String
def increment(value, n = 1)
  value.to_i + n
end

on -> (value) { value.is_a?(Array) && value.all? { |v| v.is_a?(Integer) } }
def increment(value, n = 1)
  # Should recurse into other patterns
  value.map(&Transmute.increment(n))
end

)

FAQs

Package last updated on 09 Jun 2016

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.