
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Use null_association
to utilize the null object pattern
with Active Record associations.
This gem was extracted from Keygen.
Sponsored by:
A fair source software licensing and distribution API.
Add this line to your application's Gemfile
:
gem 'null_association'
And then execute:
$ bundle
Or install it yourself as:
$ gem install null_association
To use a null object, define an optional singular association and use the
null_object:
keyword, which accepts a class name, a class, or an instance.
When the association is nil, the null object will be returned instead.
class NullObject
include Singleton
def present? = false
def blank? = true
end
class NullPlan < NullObject
def name = 'Free'
def free? = true
def pro? = false
def ent? = false
end
class NullBilling < NullObject
def subscribed? = true
def trialing? = false
def canceled? = false
end
class Account
belongs_to :plan, optional: true, null_object: NullPlan.instance
has_one :billing, null_object: NullBilling.instance
end
account = Account.create(plan: nil)
puts account.plan # => #<NullPlan name="Free">
puts account.plan.free? # => true
puts account.plan.ent? # => false
account.update(plan: Plan.new(name: 'Ent', ent: true))
puts account.plan # => #<Plan id=1 name="Ent">
puts account.plan.free? # => false
puts account.plan.ent? # => true
null_association
supports Ruby 3.1 and above. We encourage you to upgrade
if you're on an older version. Ruby 3 provides a lot of great features, like
better pattern matching and a new shorthand hash syntax.
Yes.
If you have an idea, or have discovered a bug, please open an issue or create a pull request.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that null_association 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.