
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
= Method Decorator
{}[https://travis-ci.org/r4z3c/method_decorator]
{
}[https://codeclimate.com/github/r4z3c/method_decorator]
{
}[https://codeclimate.com/github/r4z3c/method_decorator/coverage]
{
}[https://codeclimate.com/github/r4z3c/method_decorator]
Provides a way to dynamically override methods without losing original behavior.
== Example
For a given class:
class SomeClass
def some_method(some_arg)
puts some_arg
end
end
MethodDecorator.decorate SomeClass, :some_method do
puts "decorated_some_method_with: #{call_args}"
call_original
end
This call:
SomeClass.new.some_method 'some arg'
Produces this output:
decorated_some_method_with: ["some arg"]
some arg
== Helper Methods
Inside the block given to MethodDecorator.decorate
, you can call four helper methods:
call_args # returns original arguments given to the call
call_block # returns original block given to the call
call_original # call the original method, with original args and block given to the call
call_original_with # call the original method, with desired args and block
== Module inclusion
You can call decorate
method directly instead of calling MethodDecorator.decorate
. Just include MethodDecorator
module:
class SomeClass
def some_method(some_arg)
puts some_arg
end
include MethodDecorator
decorate :some_method do
puts "decorated_some_method_with: #{call_args}"
call_original
end
end
== Singleton Classes Support
It works too:
class SomeClass
class << self
def some_method(some_arg)
puts some_arg
end
end
end
MethodDecorator.decorate SomeClass.singleton_class, :some_method do
puts "decorated_some_method_with: #{call_args}"
call_original
end
SomeClass.some_method 'some arg'
== More
To see more of MethodDecorator
usages, please take a look at DummyClass[https://github.com/r4z3c/method_decorator/blob/master/spec/support/dummy_class.rb].
===
{}[https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AMPXM3PW6CTBE]
FAQs
Unknown package
We found that method_decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.