
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
'Classial' class enum for Ruby
class Animal
include Class::Enum
attr_reader :sound
def initialize(sound)
@sound = sound
end
field :CAT, "meow"
field :DOG, "bark"
field :BIRD, "tweet"
end
puts Animal::CAT.sound # meow
case Animal::CAT
when Animal
puts "An animal"
else
puts "X"
end
# An animal
Animal::CAT.instance_of?(Animal) # => true
Animal::CAT.class # => Animal
See documentation
class Animal
include Class::Enum
attr_reader :block
def initialize(&block)
@block = block
end
field :CAT do
puts "meow"
end
end
Animal::CAT.block.call # meow
You can keyword arguments only if ruby 2.0+. If not ruby 2.0+, this gem doesn't use keyword arguments
class Animal
include Class::Enum
attr_reader :sound
def initialize(sound:)
@sound = sound
end
field :CAT, sound: "meow"
end
puts Animal::CAT.sound # meow
Sputnik Gugja (sputnikgugja@gmail.com)
This is free software released into the public domain (CC0 license).
See LICENSE
file.
FAQs
Unknown package
We found that class-enum 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.