Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filtration

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filtration

  • 0.0.7
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Filtration Filtration is a clean, lightweight way to filter arguments going into and coming out of methods (similar to decorators in Python).

== Usage Example:

class Bar

def foo(x)
  x + 2
end

def foo_too(x)
  x + 2
end

def foo_as_well(x)
  "#{x.to_s} to the max!"
end

def foo_forever(x)
  "#{x.to_s} to the max!"
end

end

class Foo < Bar

prefilter(:foo){|x| x * 2}

postfilter(:foo_too){|x| x * 2}

end

randy = Foo.new randy.foo(2) #=> (x * 2) + 2 = 6 (for x = 2) randy.foo_too(2) #=> (x + 2) * 2 = 8 (for x = 2)

class AnotherFoo < Bar

prefilter :foo, :double

postfilter :foo_too, :double

def double(x)
  x * 2
end

end

savage = AnotherFoo.new savage.foo(2) #=> (x * 2) + 2 = 6 savage.foo_too(2) #=> (x + 2) * 2 => 8

class YetAnotherFoo < Bar

prefilter :foo_as_well, &:upcase

postfilter :foo_forever, &:upcase

end

machoman = YetAnotherFoo.new machoman.foo_as_well('filtration') #=> "#{x.upcase} to the max!" = 'FILTRATION to the max!' machoman.foo_forever('filtration') #=> "#{x} to the max!".upcase = 'FILTRATION TO THE MAX!'

== Requirements Filtration stands on its own!

== Development RSpec is used for testing, with SimpleCov for code coverage.

FAQs

Package last updated on 28 Oct 2011

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc