Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Transparently persist objects to disk as YAML or PStore files.
$ gem install pobject
Or with bundler:
gem 'pobject'
Your object should inherit from PObject
.
require 'pobject'
class Settings < PObject
end
Now, any time you access a property, it is saved to a file. By default, we will save a YAML file with the same name as the class.
class Settings < PObject
end
config = Settings.new
config.port = 3000
# Will create a 'settings.yml' file and store the port value
You can access any property by either dot notation or hash notation.
config.port
# => 3000
config[:port]
# => 3000
To change the location of the file, simply override the to_store
method.
class Settings < PObject
def to_store
"config/local.yml"
end
end
config = Settings.new
config.port = 3000
# Will create a 'config/local.yml'
Whenever you use the .yml
(or .yaml
) extension, we will store a YAML
file. If you wish to store a PStore
object instead, use any other
extension.
class Settings < PObject
def to_store
"config/local.pstore"
end
end
To store several objects in one store file, your to_store
method should
return an array with two elements: The first, is the path to the file and
the second is any unique key identifying the instance.
class Hero < PObject
def initialize(id)
@id = id
end
def to_store
["heroes.yml", @id]
end
end
hammer = Hero.new :hammer
raynor = Hero.new :raynor
hammer.name = 'Sgt. Hammer'
raynor.name = 'Raynor'
puts File.read 'heroes.yml'
# =>
# ---
# :hammer:
# :name: Sgt. Hammer
# :raynor:
# :name: Raynor
By default, PObject will raise an error when accessing a property that does
not exist. To change this behavior, call allow_missing
at the beinning of
your class.
class Book < PObject
allow_missing
end
book = Book.new
book.author
# => nil
FAQs
Unknown package
We found that pobject 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.